package com.sgb.kjwl.view.ui.activity;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.JavascriptInterface;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.util.Pair;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.Observer;
import androidx.navigation.NavArgument;
import androidx.navigation.fragment.NavHostFragment;

import com.alibaba.android.arouter.launcher.ARouter;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import com.im.immodel.IMUtils;
import com.sdk.mobile.manager.login.NoDoubleClickListener;
import com.sgb.alimaplibrary.util.ToastUtil;
import com.sgb.capital.callback.Constants;
import com.sgb.capital.callback.ZMessageEvent;
import com.sgb.capital.view.pop.TipPop;
import com.sgb.capital.view.ui.activity.OpenAccountFirstActivity;
import com.sgb.capital.view.ui.activity.PersonPayActivity;
import com.sgb.goods.view.activity.inquiry.InquiryPublishingActivity;
import com.sgb.jicai.view.activity.FactoryParticipationActivity;
import com.sgb.jicai.view.activity.JiCaiQuotedPriceActivity;
import com.sgb.jicai.view.activity.JoinInJiCaiActivity;
import com.sgb.kjwl.AppFragment;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.FragmentWebViewX5Binding;
import com.sgb.kjwl.di.pick.DaggerPickFragComponent;
import com.sgb.kjwl.di.pick.PickFragModule;
import com.sgb.kjwl.model.EnquiryImAlternateEntity;
import com.sgb.kjwl.model.entity.AskLeaseQuedPriceEntity;
import com.sgb.kjwl.model.entity.CallPhoneEntity;
import com.sgb.kjwl.model.entity.CarInfo;
import com.sgb.kjwl.model.entity.FindPackersEntity;
import com.sgb.kjwl.model.entity.LoginEntity;
import com.sgb.kjwl.model.entity.UserMsgEntity;
import com.sgb.kjwl.model.entity.business.AttrFileEntity3;
import com.sgb.kjwl.model.entity.lease.LeaseOrderPaymentEntity;
import com.sgb.kjwl.model.entity.lease.LeaseOrderProductEntity;
import com.sgb.kjwl.model.entity.lease.LeaseOrderReceiveEntity;
import com.sgb.kjwl.model.entity.transport.MapLongAndLatEntity;
import com.sgb.kjwl.model.entity.transport.common.AddressItem;
import com.sgb.kjwl.utils.GlideEngine;
import com.sgb.kjwl.utils.GsonUtil;
import com.sgb.kjwl.view.widget.pick.PickAuctionShareDialog;
import com.swgk.core.util.ThreadUtils;
import com.sgb.kjwl.utils.WebJsConstants;
import com.sgb.kjwl.view.ui.activity.self.lease.LeaseOrderDeviceActivity;
import com.sgb.kjwl.view.ui.activity.self.userInfo.RegisterActivity3;
import com.sgb.kjwl.view.widget.CallPhonePopWindow;
import com.sgb.kjwl.view.widget.ShareCustomerInquiryDialog;
import com.sgb.kjwl.view.widget.transport.MapNavigationDialog;
import com.sgb.link.entity.PickInvitedApply;
import com.sgb.member.MemberConfig;
import com.sgb.member.entity.QualityMemberBean2;
import com.sgb.member.ui.activity.ComApplyOrInvitePersonActivity;
import com.sgb.member.ui.activity.ComApplyOrInvitePersonShenPiActivity;
import com.sgb.member.ui.activity.PersonApplyJoinActivity;
import com.sgb.member.ui.activity.PersonInviteJoinActivity;
import com.sgb.member.util.ChooseFileUtil;
import com.sgb.member.weight.MemberCommonDialog;
import com.sgb.member.weight.SimpleResult;
import com.sgb.member.weight.UploadFileBean;
import com.swgk.core.event.EventConstant;
import com.sgb.link.event.LeaseEvent;
import com.sgb.kjwl.view.event.LeaseOrderEvent;
import com.sgb.kjwl.view.event.LoginEvent;
import com.sgb.kjwl.view.event.WebEvent;
import com.sgb.kjwl.view.ui.activity.device.DeviceDetailActivity;
import com.sgb.kjwl.view.ui.activity.house.LeaseHousesActivity;
import com.sgb.kjwl.view.ui.activity.leaseAsk.AskLeaseQuedPriceActivity;
import com.sgb.kjwl.view.ui.activity.leaseAsk.MachineOutActivity;
import com.sgb.kjwl.view.ui.activity.manage.ShopInfoForCompanyTradesActivity;
import com.sgb.kjwl.view.ui.activity.manage.WebsiteInfoActivity;
import com.sgb.kjwl.view.ui.activity.manage.WebsiteUpDataJYDTActivity;
import com.sgb.kjwl.view.ui.activity.manage.WebsiteUpDataJingYingYeJiActivity;
import com.sgb.kjwl.view.ui.activity.manage.WebsiteUpDataRongYuRongYaoActivity;
import com.sgb.kjwl.view.ui.activity.manage.WebsiteUpDataZhiShiChanQuanActivity;
import com.sgb.kjwl.view.ui.activity.manage.WebsiteUpDataZhuanXiangZiZhiActivity;
import com.sgb.kjwl.view.ui.activity.manage.special.InviteMemberPostActivity;
import com.sgb.kjwl.view.ui.activity.packers.PackersPositionActivity3;
import com.sgb.kjwl.view.ui.activity.packers.WorkEquipmentActivity;
import com.sgb.kjwl.view.ui.activity.packers.WorkPerformanceActivity;
import com.sgb.kjwl.view.ui.activity.packers.WorkPersonnelActivity;
import com.sgb.kjwl.view.ui.activity.pick.EnterpriseBiddingActivity5;
import com.sgb.kjwl.view.ui.activity.pick.PickInquireByLetterActivity;
import com.sgb.kjwl.view.ui.activity.pick.ReportActivity;
import com.sgb.kjwl.view.ui.activity.pick.TenderDetailsActivity3;
import com.sgb.kjwl.view.ui.activity.self.JoinCompanyActivity;
import com.sgb.kjwl.view.ui.activity.self.authentication.AuthActivity3;
import com.sgb.kjwl.view.ui.activity.self.authentication.CertificationActivity;
import com.sgb.kjwl.view.ui.activity.self.lease.LeaseOrderConfirmActivity;
import com.sgb.kjwl.view.ui.activity.self.lease.LeaseOrderMachineActivity;
import com.sgb.kjwl.view.ui.activity.self.lease.LeaseOrderPaymentActivity;
import com.sgb.kjwl.view.ui.activity.self.lease.LeaseOrderReceiveActivity;
import com.sgb.kjwl.view.ui.activity.self.lease.SelfLeaseOrderListActivity;
import com.sgb.kjwl.view.ui.activity.self.logistics.AddCarActivity;
import com.sgb.kjwl.view.ui.activity.self.packers.SelfBasicInformationActivity;
import com.sgb.kjwl.view.ui.activity.self.packers.SelfTeamIntroduceActivity;
import com.sgb.kjwl.view.ui.activity.self.packers.SelfWorkExperienceActivity;
import com.sgb.kjwl.view.ui.activity.self.publish.CarPublishActivity1;
import com.sgb.kjwl.view.ui.activity.self.publish.DevicePublishActivity;
import com.sgb.kjwl.view.ui.activity.self.publish.GetPositionActivity;
import com.sgb.kjwl.view.ui.activity.self.publish.LeaseFactoryActivity;
import com.sgb.kjwl.view.ui.activity.self.publish.LeaseFarmActivity;
import com.sgb.kjwl.view.ui.activity.self.publish.LeaseLandActivity;
import com.sgb.kjwl.view.ui.activity.self.publish.LeaseMachineActivity;
import com.sgb.kjwl.view.ui.activity.self.shop.ShopPriceDetailsAct;
import com.sgb.kjwl.view.ui.activity.self.userInfo.VerificationCodeLoginActivity;
import com.sgb.kjwl.view.ui.activity.transport.OfferOrderActivity;
import com.sgb.kjwl.view.ui.activity.transport.OrderBargainingActivity;
import com.sgb.kjwl.view.ui.activity.vehicleManagement.AddDriverInfoActivity;
import com.sgb.kjwl.view.widget.BaojiaTypeWindow;
import com.sgb.kjwl.view.widget.ShareLeaseDialog;
import com.sgb.kjwl.view.widget.ThreeButtonDialog;
import com.sgb.kjwl.view.widget.pick.PickEmploymentShareDialog;
import com.sgb.kjwl.viewmodel.pick.H5Model;
import com.sgb.member.entity.MemberBean;
import com.sgb.member.entity.QualityMemberBean;
import com.sgb.member.ui.activity.ChooseMemberTypeActivity;
import com.sgb.member.ui.activity.MemberApplyJoinActivity;
import com.sgb.member.ui.activity.MemberInviteJoinActivity;
import com.sgb.member.ui.activity.MemberInviteOrApplyActivity;
import com.sgb.zhaocai.view.activity.PickInvitedApplyDetailsActivity;
import com.sgb.zhaocai.view.activity.PickInvitedSignUpActivity;
import com.sgb.zhaocai.view.demand.activity.DemandIssueActivity;
import com.sgb.zhaocai.view.demand.activity.ProjectIssueActivity;
import com.sgb.zhaocai.utils.PickUtil;
import com.swgk.core.base.di.AppComponent;
import com.swgk.core.dialog.DialogHelper;
import com.swgk.core.dialog.RoundCornerDialog;
import com.swgk.core.dialog.RoundDialog;
import com.swgk.core.download.DownloadListner;
import com.swgk.core.download.DownloadManager;
import com.swgk.core.util.LogUtil;
import com.swgk.core.util.MLog;
import com.swgk.core.util.MToast;
import com.swgk.core.util.PointUtils;
import com.swgk.core.util.SharedPreferenceUtil;
import com.swgk.core.view.selection.CommonPopEntity;
import com.swgk.core.view.selection.CopyUtils;
import com.tencent.smtt.sdk.WebSettings;
import com.tencent.smtt.sdk.WebView;
import com.ycbjie.webviewlib.base.X5WebChromeClient;
import com.ycbjie.webviewlib.bridge.BridgeUtil;
import com.ycbjie.webviewlib.bridge.DefaultHandler;
import com.ycbjie.webviewlib.bridge.WebJsMessage;
import com.ycbjie.webviewlib.inter.CallBackFunction;
import com.ycbjie.webviewlib.view.BridgeWebView;
import com.ycbjie.webviewlib.view.X5WebView;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.inject.Inject;

import static android.app.Activity.RESULT_OK;
import static com.sgb.kjwl.view.ui.activity.WebViewX5HostActivity.TEXT;

/**
 * Created by harisucici on 2020/5/14
 * Class description:
 */
public class WebViewX5Fragment extends AppFragment {

    public boolean isEdt = false; //是否是编辑界面保存成功返回

    private static final int REQ_MEMBER_TYPE_CODE = 3;

    private static FragmentWebViewX5Binding binding;
    private final static String TAG = "WebViewX5Fragment";
    private String url;
    private static X5WebChromeClient chromeClient;
    private String id;
    private String type;
    private String status;
    @Inject
    H5Model viewModel;
    private List<CarInfo> carInfo;
    private String lat;
    private String lng;
    private String historyUrl;

    //    private BaojiaTypeWindow baojiaTypeWindow;
    private PickEmploymentShareDialog dialog;
    //地图导航弹窗
    private MapNavigationDialog mNavigationDialog;
    private TipPop mTipPop;
    private boolean mAcceptanceRefresh = false;
    private String selestFile = ""; //要选择的文件路径格式
    private String sharTitleText = "";
    private PickAuctionShareDialog pickdialog;//拍卖详情分享

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater, R.layout.fragment_web_view_x5, container, false);
        return binding.getRoot();
    }

    public void loadUrl(String url) {
        historyUrl = url;
        Log.e("WebViewX5Fragment", url);
        binding.webViewX5.clearCache(true);
        binding.webViewX5.loadUrl(url);
    }

    public void setId(String id) {
        Log.e("WebViewX5Fragment", id);
        this.id = id;
    }


    public void setType(String type) {
        this.type = type;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        Map<String, NavArgument> map = NavHostFragment.findNavController(WebViewX5Fragment.this).getGraph().getArguments();
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }
        type = getActivity().getIntent().getStringExtra("TYPE");
        status = getActivity().getIntent().getStringExtra("STATE");
        sharTitleText = getActivity().getIntent().getStringExtra("sharTitleText");
        NavArgument navArgument = map.get(WebViewX5HostActivity.URL);
        if (null != navArgument) {
            url = (String) navArgument.getDefaultValue();
        }
        memberTypes = new ArrayList<>();
        initView();
        initWebSetting();
        initDialog();
        initWebViewBridge();
        initObserve();
    }

    @Override
    protected void setupFragmentComponent(AppComponent appComponent) {
        DaggerPickFragComponent.builder()
                .appComponent(appComponent)
                .pickFragModule(new PickFragModule(this))
                .build()
                .inject(this);
    }

    private static List<CommonPopEntity> memberTypes = new ArrayList<>();

    public void ActivityResult(int requestCode, int resultCode, Intent intent) {
        if (requestCode == X5WebChromeClient.FILE_CHOOSER_RESULT_CODE) {
            chromeClient.uploadMessage(intent, resultCode);
        } else if (requestCode == X5WebChromeClient.FILE_CHOOSER_RESULT_CODE_5) {
            chromeClient.uploadMessageForAndroid5(intent, resultCode);
        }
        if (resultCode == RESULT_OK && requestCode == MemberConfig.REQ_FILE_CHOOSE) {//选择文件返回
            if (intent == null) {
                selestFile = "";
                LogUtil.d("TAG", "onActivityResult chooseFile data is null");
                return;
            }
            ChooseFileUtil.handleFileChoose(getWebView().getContext(), intent, new SimpleResult<UploadFileBean>() {
                @Override
                public void onResult(UploadFileBean uploadFileBean, Object... objects) {
                    String fileType = uploadFileBean.getExtension();
                    if (!selestFile.contains(fileType)) {
                        MToast.showToast(getActivity(), "选择文件格式不支持上传！");
                    } else {
                        if (uploadFileBean != null) {
                            viewModel.uploadSingleFile(uploadFileBean);
                        }
                    }
                    selestFile = "";
                }
            }, 10);
        } else {
            // 自定义回调
            if (resultCode == RESULT_OK && requestCode == REQ_MEMBER_TYPE_CODE) {
                memberTypes = (List<CommonPopEntity>) intent.getSerializableExtra("MEMBER_DATA");
                Map<String, List<CommonPopEntity>> map = CopyUtils.memberTypeToJson(memberTypes);
                binding.webViewX5.callHandler(WebJsConstants.GET_MEMBER_TYPE, new Gson().toJson(map), new CallBackFunction() {
                    @Override
                    public void onCallBack(String data) {
                        Log.d("REQ_MEMBER_TYPE_CODE", "callHandler data : " + data);
                    }
                });
            }
        }
    }

    /**
     * LiveData 数据回掉
     */
    private void initObserve() {
        //文件上传
        viewModel.mFileData.observe(getViewLifecycleOwner(), new Observer<UploadFileBean>() {
            @Override
            public void onChanged(UploadFileBean uploadFileBean) {
                if (uploadFileBean != null && !TextUtils.isEmpty(uploadFileBean.getUrlPath())) {
                    LogUtil.e("文件获取路径", "文件路径" + uploadFileBean.toString());
                    MToast.showToast(getActivity(), "文件上传成功！");
                    Map<String, List<UploadFileBean>> map = new HashMap<>();
                    List<UploadFileBean> url = new ArrayList<>();
                    url.add(uploadFileBean);
                    map.put("fileUrl", url);
                    binding.webViewX5.callHandler(WebJsConstants.GETFILEURL, new Gson().toJson(map), new CallBackFunction() {
                        @Override
                        public void onCallBack(String data) {
                            Log.d("GETFILEURL", "callHandler data : " + data);
                        }
                    });
                } else {
                    MToast.showToast(getActivity(), "文件上传失败！");
                }
            }
        });
    }


    private void initDialog() {
    }

    private Map<String, Object> getMapToken() {
        Map<String, Object> mapToken = new HashMap<>();
        if (TextUtils.isEmpty(viewModel.getToken())) {
            mapToken.put(WebJsConstants.KEY_PC_TOKEN, "");
            mapToken.put(WebJsConstants.KEY_APP_TOKEN, "");
            mapToken.put(WebJsConstants.KEY_JWT_TOKEN, "");
        } else {
            mapToken.put(WebJsConstants.KEY_PC_TOKEN, SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.resourcePCToken, ""));
            mapToken.put(WebJsConstants.KEY_APP_TOKEN, SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.resourceAPPToken, ""));
            mapToken.put(WebJsConstants.KEY_JWT_TOKEN, SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""));
        }
        return mapToken;
    }

    private void initView() {
        if ("1".equals(type)) {
            if ("1".equals(status)) {
//                binding.include.rightImageView.setImageResource(R.mipmap.gengduo);
                binding.include.rightImageView.setVisibility(View.GONE);
                binding.include.rightView.setVisibility(View.GONE);

//                binding.include.rightImageView.setOnClickListener(v -> {
//                    baojiaTypeWindow.showPopwindow(binding.include.rightImageView, true, 20);
//                });
                binding.include.shareImageView.setVisibility(View.VISIBLE);
                binding.include.shareImageView.setOnClickListener(v -> {
                    ShareCustomerInquiryDialog customerInquiryDialog = new ShareCustomerInquiryDialog(getActivity());
                    customerInquiryDialog.init(historyUrl, sharTitleText);
                });
                binding.textDelete1Inquiry.setVisibility(View.GONE);
                binding.textAginInquiry.setVisibility(View.GONE);
                binding.textDeleteInquiry.setVisibility(View.GONE);
                binding.textColoseInquiry.setVisibility(View.VISIBLE);
                binding.textUpdateInquiry.setVisibility(View.VISIBLE);

                binding.textColoseInquiry.setOnClickListener(view -> {
                    //取消
                    new RoundDialog.Builder(getActivity())
                            .title("温馨提示")
                            .content("取消询价，询价单将失效无法\n" +
                                    "进行报价，还要继续吗？")
                            .cancel("取消")
                            .confirm("确定")
                            .singleBtn(false)
                            .contentGravity(Gravity.CENTER)
                            .cancelable(false)
                            .confirmCallback(v -> viewModel.enquiryCancel(getActivity().getIntent().getStringExtra("id")))
                            .show();
                });
                binding.textUpdateInquiry.setOnClickListener(view -> {
                    ARouter.getInstance().build(com.sgb.goods.utils.Constants.ARouter.AR_INQUIRY_PUBLISHING)
                            .withString(InquiryPublishingActivity.KEY_GOOD_RESOURCE_ID, getActivity().getIntent().getStringExtra("id"))
                            .withString(InquiryPublishingActivity.KEY_GOOD_FROM_WHERE, "1")
                            .navigation();

                    getActivity().finish();
                });

            } else if ("2".equals(status)) {
                binding.include.rightImageView.setVisibility(View.GONE);
//                binding.include.rightView.setText("取消询价");
//                binding.include.rightView.setVisibility(View.VISIBLE);
                binding.include.shareImageView.setVisibility(View.VISIBLE);
                binding.include.shareImageView.setOnClickListener(v -> {
                    ShareCustomerInquiryDialog customerInquiryDialog = new ShareCustomerInquiryDialog(getActivity());
                    customerInquiryDialog.init(historyUrl, sharTitleText);
                });
                binding.include.rightView.setVisibility(View.GONE);
                binding.textDelete1Inquiry.setVisibility(View.GONE);
                binding.textAginInquiry.setVisibility(View.GONE);
                binding.textColoseInquiry.setVisibility(View.GONE);
                binding.textUpdateInquiry.setVisibility(View.GONE);
                binding.textDeleteInquiry.setVisibility(View.VISIBLE);
                binding.textDeleteInquiry.setOnClickListener(v -> {
                    //取消
                    new RoundDialog.Builder(getActivity())
                            .title("温馨提示")
                            .content("取消询价，询价单将失效无法\n" +
                                    "进行报价，还要继续吗？")
                            .cancel("取消")
                            .confirm("确定")
                            .singleBtn(false)
                            .contentGravity(Gravity.CENTER)
                            .cancelable(false)
                            .confirmCallback(v1 -> viewModel.enquiryCancel(getActivity().getIntent().getStringExtra("id")))
                            .show();
                });

            } else if ("4".equals(status)) {
                binding.include.rightImageView.setVisibility(View.GONE);
                binding.include.rightView.setVisibility(View.GONE);

                binding.textColoseInquiry.setVisibility(View.GONE);
                binding.textUpdateInquiry.setVisibility(View.GONE);
                binding.textDeleteInquiry.setVisibility(View.GONE);
                binding.textDelete1Inquiry.setVisibility(View.VISIBLE);
                binding.textAginInquiry.setVisibility(View.VISIBLE);
                binding.textDelete1Inquiry.setOnClickListener(v -> {
                    new RoundDialog.Builder(getActivity())
                            .title("温馨提示")
                            .content("确定要删除该条询价单吗?")
                            .cancel("取消")
                            .confirm("确定")
                            .singleBtn(false)
                            .contentGravity(Gravity.CENTER)
                            .cancelable(false)
                            .confirmCallback(v12 -> viewModel.enquiryDelete(getActivity().getIntent().getStringExtra("id")))
                            .show();
                });

                binding.textAginInquiry.setOnClickListener(view -> {
                    ARouter.getInstance().build(com.sgb.goods.utils.Constants.ARouter.AR_INQUIRY_PUBLISHING)
                            .withString(InquiryPublishingActivity.KEY_GOOD_RESOURCE_ID, getActivity().getIntent().getStringExtra("id"))
                            .withString(InquiryPublishingActivity.KEY_GOOD_FROM_WHERE, "2")
                            .navigation();

                    getActivity().finish();
                });

            } else {
                binding.include.rightView.setVisibility(View.GONE);
            }
        } else if ("lease".equals(type) || "asklease".equals(type)) {
            binding.include.rightView.setVisibility(View.GONE);
            binding.include.rightImageView.setVisibility(View.VISIBLE);
            binding.include.rightImageView.setImageResource(R.mipmap.ic_share_white);
            binding.include.rightImageView.setOnClickListener(new NoDoubleClickListener() {
                @Override
                public void onNoDoubleClick(View view) {
                    ShareLeaseDialog leaseDialog = new ShareLeaseDialog(getActivity());
                    leaseDialog.init(type, status, id);
                }
            });
        } else if ("customerinquiry".equals(type)) {
            binding.include.rightView.setVisibility(View.GONE);
            binding.include.shareImageView.setVisibility(View.VISIBLE);
            binding.include.shareImageView.setOnClickListener(new NoDoubleClickListener() {
                @Override
                public void onNoDoubleClick(View view) {
                    ShareCustomerInquiryDialog customerInquiryDialog = new ShareCustomerInquiryDialog(getActivity());
                    customerInquiryDialog.init(historyUrl, status);
                }
            });
        } else {
            binding.include.rightView.setText("");
            binding.include.rightView.setVisibility(View.GONE);
        }

        binding.include.ivBack.setOnClickListener(view -> {
            goBack();
        });

//        baojiaTypeWindow = new BaojiaTypeWindow(getActivity());
//        baojiaTypeWindow.setOnClickCallBack(new BaojiaTypeWindow.OnClickCallBack() {
//            @Override
//            public void scan() {
//                //修改
//                ARouter.getInstance().build(com.sgb.goods.utils.Constants.ARouter.AR_INQUIRY_PUBLISHING)
//                        .withString(InquiryPublishingActivity.KEY_GOOD_RESOURCE_ID, getActivity().getIntent().getStringExtra("id"))
//                        .navigation();
//
//                getActivity().finish();
//            }
//
//            @Override
//            public void message() {
//                //取消
//                new RoundDialog.Builder(getActivity())
//                        .title("温馨提示")
//                        .content("取消询价，询价单将失效无法\n" +
//                                "进行报价，还要继续吗？")
//                        .cancel("取消")
//                        .confirm("确定")
//                        .singleBtn(false)
//                        .contentGravity(Gravity.CENTER)
//                        .cancelable(false)
//                        .confirmCallback(v -> viewModel.enquiryCancel(getActivity().getIntent().getStringExtra("id")))
//                        .show();
//            }
//        });

    }

    public void goBack() {
        if (!TextUtils.isEmpty(binding.webViewX5.getUrl()) && binding.webViewX5.getUrl().contains("successDetail") || //函询
                (!TextUtils.isEmpty(binding.webViewX5.getUrl()) && binding.webViewX5.getUrl().contains("userCenterMemberAcceptUpdate") && mAcceptanceRefresh)
        ) {
            getActivity().setResult(RESULT_OK);
            getActivity().finish();
        } else {
            //一般返回
            if (binding.webViewX5.canGoBack()) {
                binding.webViewX5.goBack();
            } else {
                getActivity().finish();
            }
        }
    }

    public static X5WebView getWebView() {
        return binding.webViewX5;
    }

    private boolean isShowContent = false;

    private void initWebSetting() {
        binding.webViewX5.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                return false;
            }
        });
        binding.progress.show();
        binding.progress.setColor(this.getResources().getColor(R.color.translucent));
        binding.webViewX5.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
        binding.webViewX5.getSettings().setDomStorageEnabled(true);
        binding.webViewX5.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
        binding.webViewX5.getSettings().setAppCacheEnabled(true);
        binding.webViewX5.setOnLongClickListener(v -> {
            return true;
        });//解决长按会弹出保存对话框的问题造成的闪退
        chromeClient = new X5WebChromeClient(binding.webViewX5, getActivity()) {
            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                super.onProgressChanged(view, newProgress);
                Log.e("WebViewX5Activity", newProgress + "");
                if (Thread.currentThread() == Looper.getMainLooper().getThread()) {
                    WebViewX5HostActivity activity = (WebViewX5HostActivity) getActivity();
                    if (newProgress == 100) {
                        if (activity == null) {
                            return;
                        }
                        activity.closeLoadingView();
                    }
                    int max = 85;
                    if (newProgress > max && !isShowContent) {
                        //在这个时候添加js注入方法，具体可以看readme文档
                        BridgeUtil.webViewLoadLocalJs(view, BridgeWebView.TO_LOAD_JS);
                        if (binding.webViewX5.getStartupMessage() != null) {
                            for (WebJsMessage m : binding.webViewX5.getStartupMessage()) {
                                binding.webViewX5.dispatchMessage(m);
                            }
                            binding.webViewX5.setStartupMessage(null);
                        }
                        isShowContent = true;
                    }
                }
            }
        };
        jsGetToken();
        binding.webViewX5.setWebChromeClient(chromeClient);
        binding.webViewX5.loadUrl(url);
        Log.v("tokkk", "oncreate");
    }

    /**
     *
     */
    // 注册JS方法 js调用java
    @JavascriptInterface
    public void initWebViewBridge() {
        binding.webViewX5.setDefaultHandler(new DefaultHandler());
        //标题--js调java
        binding.webViewX5.registerHandler(WebJsConstants.SEND_TITLE, (data, function) -> {
            TitleEntity titleEntity = new Gson().fromJson(data, TitleEntity.class);
            Log.e("tag分享数据信息", titleEntity.toString() + "\n" + data.toString());
            if (!TextUtils.isEmpty(titleEntity.getTitle())) {
                if (titleEntity.getTitle().length() <= 15) {
                    binding.include.titleView.setText(titleEntity.getTitle());
                } else {
                    binding.include.titleView.setText(titleEntity.getTitle().substring(0, 12) + "...");
                }
            } else {
                binding.include.titleView.setText("");
            }

            //右侧按钮判断 - 租赁审批日志显示
            if (titleEntity.hasApply && !TextUtils.isEmpty(titleEntity.url)) {
                binding.include.rightView.setText("审批日志");
                binding.include.rightView.setVisibility(View.VISIBLE);
                binding.include.rightView.setOnClickListener(v -> {
                    WebViewX5HostActivity.start(getActivity(), titleEntity.url);
                });
            }
            //右侧按钮判断 - 是否显示竞价分享按钮
            if (titleEntity.showShare) {
                binding.include.shareImageView.setVisibility(View.VISIBLE);
                binding.include.shareImageView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        //titleEntity.getType()用来区分是不是需求预告
                        if (!TextUtils.isEmpty(titleEntity.getType())) {
                            switch (titleEntity.getType()) {
                                case "1":
                                    //分包计划
                                    dialog = new PickEmploymentShareDialog(titleEntity.getName(), titleEntity.getWeixinFenXiangUrl(),
                                            titleEntity.getWeixinFenXiangMsg(), titleEntity.getItemBusinessControlAmount(), titleEntity.getAddrDetail(), titleEntity.companyName, 5, getActivity(), null);
                                    break;
                                case "2":
                                    //工程项目
                                    dialog = new PickEmploymentShareDialog(titleEntity.getName(), titleEntity.getWeixinFenXiangUrl(),
                                            titleEntity.getWeixinFenXiangMsg(), titleEntity.getProjectPrice(), titleEntity.getAddrDetail(), titleEntity.companyName, 6, getActivity(), null);
                                    break;
                                case "jingjia":
                                    dialog = new PickEmploymentShareDialog(titleEntity.title, titleEntity.getWeixinFenXiangUrl(),
                                            titleEntity.getWeixinFenXiangMsg(), titleEntity.BidType, titleEntity.getBudgetPrice(), titleEntity.companyName, 3, getActivity(), null);
                                    break;
                                case "business":
                                    dialog = new PickEmploymentShareDialog(titleEntity.getName(), titleEntity.getWeixinFenXiangUrl(),
                                            titleEntity.getWeixinFenXiangMsg(), titleEntity.BidType, titleEntity.getBudgetPrice(), titleEntity.companyName, 7, getActivity(), null);
                                    break;
                                case "jingpaixiangqing"://拍卖详情分享实现
                                    pickdialog = new PickAuctionShareDialog(titleEntity.getName(), titleEntity.getWeixinFenXiangUrl(),
                                            titleEntity.getWeixinFenXiangMsg(), titleEntity.getImage(), titleEntity.getAddress(), PointUtils.priceAll(titleEntity.getCurrentPrice()) + "元", 1, getActivity(), titleEntity.getState(), titleEntity.getVersion(), null);
                                    break;
                            }
                        }
                        if (dialog != null) {
                            dialog.setDialogClickCallBack(new PickEmploymentShareDialog.DialogClickCallBack() {
                                @Override
                                public void onItemClick(String name) {
                                    getActivity().runOnUiThread(new Runnable() {
                                        @Override
                                        public void run() {
                                            ToastUtil.show(getContext(), name);
                                        }
                                    });
                                }
                            }).show();
                        }
                        if (pickdialog != null) {
                            pickdialog.setDialogClickCallBack(new PickAuctionShareDialog.DialogClickCallBack() {
                                @Override
                                public void onItemClick(String name) {
                                    getActivity().runOnUiThread(new Runnable() {
                                        @Override
                                        public void run() {
                                            ToastUtil.show(getContext(), name);
                                        }
                                    });
                                }
                            }).show();
                        }
                    }
                });
            } else {
            }

            Log.d("SEND_TITLE", "registerHandler data : " + data);
            function.onCallBack(data);
        });
        //token--js调java
        binding.webViewX5.registerHandler(WebJsConstants.Sync_Token, (data, function) -> {
            function.onCallBack(new Gson().toJson(getMapToken()));
        });
        //文件选择--js调java
        binding.webViewX5.registerHandler(WebJsConstants.GETFILES, (data, function) -> {
            TitleEntity titleEntity = new Gson().fromJson(data, TitleEntity.class);
            selestFile = titleEntity.getType();
            //打开文件管理
            ChooseFileUtil.startFileIntent(getActivity());
        });
        binding.webViewX5.registerHandler(WebJsConstants.CLOSE_PAGE, (data, function) -> {
            getActivity().setResult(Activity.RESULT_OK);
            getActivity().onBackPressed();
        });
        binding.webViewX5.registerHandler(WebJsConstants.CLOSE_PAGE, (data, function) -> {
            getActivity().setResult(Activity.RESULT_OK);
            getActivity().onBackPressed();
        });
        //去竞价,招标
        binding.webViewX5.registerHandler(WebJsConstants.GO_TO_BID, (data, function) -> {
            id = new Gson().fromJson(data, TitleEntity.class).getId();
            lat = new Gson().fromJson(data, TitleEntity.class).getLat();
            lng = new Gson().fromJson(data, TitleEntity.class).getLng();
            type = new Gson().fromJson(data, TitleEntity.class).getType();
            int value = new Gson().fromJson(data, TitleEntity.class).getValue();
            int state = new Gson().fromJson(data, TitleEntity.class).getState();
            int num = new Gson().fromJson(data, TitleEntity.class).getNum();
            if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                jumpLogin();
            } else {
                if (type.equals("jingjia")) {
                    checkAllowBid(type, 0, -100);
                } else if (type.equals("zhaobiao")) {
                    if (num == 1) {
                        type = "sq";
                    }
                    checkAllowBid(type, value, state);
                }
            }
        });
        //去客服
        binding.webViewX5.registerHandler(WebJsConstants.GO_TO_SERVICE, (data, function) -> {
            String imAccount = new Gson().fromJson(data, TitleEntity.class).getId();
            if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                jumpLogin();
            } else {
                if (imAccount != null) {
//                    MToast.showToast(getActivity(), "功能暂未开放");
//                    NimUIKit.startP2PSession(getActivity(), imAccount);
                    IMUtils.getInstance().buildSingleTalking(imAccount);
                } else {
                    checkAllowDialog("招标方未设置客服人员，不支持交流。");
                }
            }
        });
        //交流
        binding.webViewX5.registerHandler(WebJsConstants.GO_SERVICE, (data, function) -> {
            String customerServiceId = new Gson().fromJson(data, TitleEntity.class).getId();
            if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                jumpLogin();
            } else {
                if (customerServiceId != null) {
                    //  viewModel.findCustomerServiceImAccount(customerServiceId);
                    IMUtils.getInstance().buildSingleTalking(customerServiceId);
                } else {
                    checkAllowDialog("招标方未设置客服人员，不支持交流。");
                }
            }
        });
        //去函询
        binding.webViewX5.registerHandler(WebJsConstants.GO_TO_REPLY, (data, function) -> {
            TitleEntity titleEntity = new Gson().fromJson(data, TitleEntity.class);
            id = titleEntity.getId();
            String type = titleEntity.getType();
            String inquiryUserMemberNo = titleEntity.getInquiryUserMemberNo();//
            if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                jumpLogin();
            } else {
                if (type.equals("jc")) {
                    viewModel.checkAllowJcQuestion(id, inquiryUserMemberNo);
                } else if (type.equals("cjjc")) {//供方发起
                    viewModel.checkAllowFactoryJcQuestion(id, inquiryUserMemberNo);
                } else if (type.equals("jingjia")) {
                    viewModel.checkAllowBidQuestion(id, titleEntity.getBidtype());
                } else if (type.equals("zhaobiao")) {
                    viewModel.checkAllowTenderQuestion(id, titleEntity.getBidType());
                }
            }
        });
        //去举报
        binding.webViewX5.registerHandler(WebJsConstants.GO_TO_REPORT, (data, function) -> {
            String id = new Gson().fromJson(data, TitleEntity.class).getId();
            String type = new Gson().fromJson(data, TitleEntity.class).getType();
            String businessType = "";
            if ("zhaobiao".equals(type)) {
                businessType = "1";
            } else if ("jingjia".equals(type)) {
                businessType = "2";
            }
            ReportActivity.start(getActivity(), id, businessType);
        });
        //去招标详情
        binding.webViewX5.registerHandler(WebJsConstants.GO_TO_TENDER, (data, function) -> {
            String id = new Gson().fromJson(data, TitleEntity.class).getId();
            TenderDetailsActivity3.start(getActivity(), id, 0);
        });

        //租赁-去函询
        binding.webViewX5.registerHandler(WebJsConstants.GO_TO_REPLY_RENT, (data, function) -> {
            try {
                /** id = ''  // 租赁的no
                 modelType = 5 // 业务类型: 4 出租, 5 求租, 6 报价
                 markType = 3 // (函询类型：1机械， 2 设备，3车辆，4 房产，5土地，6工厂，7农机 )
                 markName = ''  // 租赁的业务标题
                 */
                JSONObject jsonObject = new JSONObject(data);
                String id = jsonObject.optString("id");
                String markType = jsonObject.optString("markType");//(函询类型：1机械， 2 设备，3车辆，4 房产，5土地，6工厂，7农机 )
                String createUserNo = jsonObject.optString("createUserNo", null);
                String createCompanyNo = jsonObject.optString("createCompanyNo", null);
                String markName = jsonObject.optString("markName", "");// 租赁的业务标题
                String modelType = jsonObject.optString("modelType");// 业务类型: 4 出租, 5 求租, 6 报价
                //H5 已做登录和验证判断
                PickInquireByLetterActivity.startLease(getActivity(), id, "ZL", createCompanyNo, createUserNo, markType, markName, modelType);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        });

        //去企业详情
        binding.webViewX5.registerHandler(WebJsConstants.GO_TO_COMPANY, (data, function) -> {
            String id = new Gson().fromJson(data, TitleEntity.class).getId();
            if (!TextUtils.isEmpty(id)) {
                WebsiteInfoActivity.start(getActivity(), id, WebsiteInfoActivity.WEBSITE_FOR_COMPANY);
            } else {
                MToast.showToast(getActivity(), "获取企业信息失败！");
            }
        });
        //去企业店铺
        binding.webViewX5.registerHandler(WebJsConstants.GO_TO_COMPANY_SHOP, (data, function) -> {
            String id = new Gson().fromJson(data, TitleEntity.class).getSupplierId();
            String companyNo = new Gson().fromJson(data, TitleEntity.class).getCompanyNo();
            Log.e(TAG, "registerHandler2: " + id);
            Intent intent = new Intent(getActivity(), ShopInfoForCompanyTradesActivity.class);
            if (id != null) {
                intent.putExtra("id", id);
                intent.putExtra("companyNo", companyNo);
                intent.putExtra("position", 3);
                intent.putExtra("childPosition", 0);
                getActivity().startActivity(intent);
            } else {
                MToast.showToast(getActivity(), "店铺id为空");
            }
        });
        //去企业网站
        binding.webViewX5.registerHandler(WebJsConstants.GO_TO_COMPANY_WEB, (data, function) -> {
            String companyNo = new Gson().fromJson(data, TitleEntity.class).getCompanyNo();
            if (!TextUtils.isEmpty(companyNo)) {
                WebsiteInfoActivity.start(getActivity(), companyNo, WebsiteInfoActivity.WEBSITE_FOR_COMPANY);
            } else {
                MToast.showToast(getActivity(), "获取企业信息失败！");
            }
        });
        //打电话
        binding.webViewX5.registerHandler(WebJsConstants.GO_TO_PHONE, (data, function) -> {
            String id = new Gson().fromJson(data, TitleEntity.class).getId();
            showDialog(id);
        });
        binding.webViewX5.registerHandler(WebJsConstants.JUDGE_CALL_PHON, (data, function) -> {
            String id = new Gson().fromJson(data, TelEntity.class).getTel();
            if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                VerificationCodeLoginActivity.start(getActivity(), EventConstant.EVENT_WEB_VIEW_JUMP);
            } else {
                if (SharedPreferenceUtil.getInstance().getSaveBooleanData(SharedPreferenceUtil.PERSON_AUTH, false)) {
                    showDialog(id);
                } else {
                    showDialog();
                }
            }

        });

        //去登录
        binding.webViewX5.registerHandler(WebJsConstants.GO_TO_LOGIN, (data, function) -> {
            viewModel.logOutUserInfo();
            VerificationCodeLoginActivity.start(getActivity(), EventConstant.EVENT_WEB_VIEW_JUMP);
        });
        //结束
        binding.webViewX5.registerHandler(WebJsConstants.GO_BACK_LIST, (data, function) -> {
            getActivity().finish();
        });

        //跳转地图
        binding.webViewX5.registerHandler(WebJsConstants.GO_TO_MAP, (data, function) -> {
            MapLongAndLatEntity entity = new Gson().fromJson(data, MapLongAndLatEntity.class);
            try {
                Double lat = Double.valueOf(entity.getLat());
                Double lng = Double.valueOf(entity.getLng());
                GetPositionActivity.start(getActivity(), lng, lat, entity.getAddress(), entity.getCompanyName());
            } catch (Exception e) {
            }
        });

        //跳转团队地图
        binding.webViewX5.registerHandler(WebJsConstants.GO_TO_TEAM_MAP, (data, function) -> {
            MapLongAndLatEntity entity = new Gson().fromJson(data, MapLongAndLatEntity.class);
            PackersPositionActivity3.start(getActivity(), Double.valueOf(entity.getLng()), Double.valueOf(entity.getLat()), entity.getAddress());
        });

        //询价
        binding.webViewX5.registerHandler(WebJsConstants.OWNER_INQUIRY, (data, function) -> {
            String id = new Gson().fromJson(data, TitleEntity.class).getId();
            if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                jumpLogin();
            } else {
                String manager = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.ENTERPRISE_AUTH, "");
                if (manager.equals("SUCCESS")) {
                    OrderBargainingActivity.start(getActivity(), OrderBargainingActivity.BARGAINING, id);
                } else {
                    switch (manager) {
                        case "FAIL":
                            showDialogAuth("managerFail");
                            break;
                        case "STANDBY":
                            showDialogAuth("managerStandby");
                            break;
                        default:
                            showDialogAuth("manager");
                            break;
                    }
                }
            }
        });
        //我的询价详情页 收到报价-交流按钮
        binding.webViewX5.registerHandler(WebJsConstants.MY_ENQUIRY_IM_ALTERNATE, (data, function) -> {
            //调取接口查询IM功能
            AttrFileEntity3 entity = new Gson().fromJson(data, AttrFileEntity3.class);
            viewModel.enquiryOrQuoteImAlternate(entity.getNo(), "2");
        });
        //我的报价报价详情 在线交流按钮
        binding.webViewX5.registerHandler(WebJsConstants.MY_QUOTE_IM_ALTERNATE, (data, function) -> {
            AttrFileEntity3 entity = new Gson().fromJson(data, AttrFileEntity3.class);
            viewModel.enquiryOrQuoteImAlternate(entity.getNo(), "1");
        });
        //下单
        binding.webViewX5.registerHandler(WebJsConstants.OWNERPLACE_ORDER, (data, function) -> {
            String id = new Gson().fromJson(data, TitleEntity.class).getId();
            if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                jumpLogin();
            } else {
                String manager = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.ENTERPRISE_AUTH, "");
                if (manager.equals("SUCCESS")) {
                    OrderBargainingActivity.start(getActivity(), OrderBargainingActivity.ORDER, id);
                } else {
                    switch (manager) {
                        case "FAIL":
                            showDialogAuth("managerFail");
                            break;
                        case "STANDBY":
                            showDialogAuth("managerStandby");
                            break;
                        default:
                            showDialogAuth("manager");
                            break;
                    }

                }
            }
        });
        //IM沟通
        binding.webViewX5.registerHandler(WebJsConstants.GO_TO_IM, (data, function) -> {
            String telephone = new Gson().fromJson(data, TitleEntity.class).getTelephone();
            if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                jumpLogin();

            } else {
                viewModel.toIm(telephone);
            }
        });
        //接单
        binding.webViewX5.registerHandler(WebJsConstants.WANTTAKEORDER, (data, function) -> {
            String id = new Gson().fromJson(data, TitleEntity.class).getId();
            String freight = new Gson().fromJson(data, TitleEntity.class).getFreight();
            if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                jumpLogin();
            } else {
                String driver = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.DRIVER_AUTH, "");
                if (driver.equals("SUCCESS")) {
                    if (carInfo != null && carInfo.size() > 0) {
                        OfferOrderActivity.start(getActivity(), OfferOrderActivity.ORDER, id, freight);
                    } else {
                        showDialogAuth("nocar");
                    }
                } else {
                    switch (driver) {
                        case "FAIL":
                            showDialogAuth("driverFail");
                            break;
                        case "STANDBY":
                            showDialogAuth("driverStandby");
                            break;
                        default:
                            showDialogAuth("driver");
                            break;
                    }
                }
            }
        });

        //报价
        binding.webViewX5.registerHandler(WebJsConstants.WANTMAKEOFFER, (data, function) -> {
            String id = new Gson().fromJson(data, TitleEntity.class).getId();
            if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                jumpLogin();
            } else {
                String driver = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.DRIVER_AUTH, "");
                if (driver.equals("SUCCESS")) {

                    if (carInfo != null && carInfo.size() > 0) {
                        OfferOrderActivity.start(getActivity(), OfferOrderActivity.OFFER, id, "");
                    } else {
                        showDialogAuth("nocar");
                    }
                } else {
                    switch (driver) {
                        case "FAIL":
                            showDialogAuth("driverFail");
                            break;
                        case "STANDBY":
                            showDialogAuth("driverStandby");
                            break;
                        default:
                            showDialogAuth("driver");
                            break;
                    }
                }
            }
        });

        //租赁-我的求租-一键报价
        binding.webViewX5.registerHandler(WebJsConstants.LEASE_ASK_QUOTE, (data, function) -> {
            AskLeaseQuedPriceEntity entity = new Gson().fromJson(data, AskLeaseQuedPriceEntity.class);
            AskLeaseQuedPriceActivity.start(getActivity(),
                    entity.getId(),
                    entity.getType(),
                    entity.getQuoteUtil(),
                    entity.getNegotiable(),
                    entity.getSecondCategoryName(),
                    entity.getCountUnit(),
                    entity.getTimeUnit(),
                    entity.getAcreage(),
                    entity.getBrandNo(),
                    entity.getBrandName(),
                    entity.getModelNo(),
                    entity.getModelName());
        });

        //租赁-编辑 点击详情编辑跳转到App编辑界面( markType:"1"机械, 2设备, 3车辆,4房产, 5土地,6工厂,7农机)
        binding.webViewX5.registerHandler(WebJsConstants.PROPERTY_EDIT, (data, function) -> {
            TitleEntity entity = new Gson().fromJson(data, TitleEntity.class);
            String markType = entity.getMarkType();
            if ("1".equals(markType)) {
                LeaseMachineActivity.start(getActivity(), entity.getNo());
            } else if ("2".equals(markType)) {
                DevicePublishActivity.start(getActivity(), entity.getId());
            } else if ("3".equals(markType)) {
                CarPublishActivity1.start(getActivity(), entity.getId());
            } else if ("4".equals(markType)) {
                LeaseHousesActivity.start(getActivity(), entity.getId());
            } else if ("5".equals(markType)) {
                LeaseLandActivity.start(getActivity(), entity.getId());
            } else if ("6".equals(markType)) {
                LeaseFactoryActivity.start(getActivity(), entity.getId());
            } else if ("7".equals(markType)) {
                LeaseFarmActivity.start(getActivity(), entity.getId());
            }
        });

        //去招采经营-项目管理-编辑界面
        binding.webViewX5.registerHandler(WebJsConstants.ProjectManagementEditor, (data, function) -> {
            id = new Gson().fromJson(data, TitleEntity.class).getId();
            startActivity(new Intent(getActivity(), ProjectIssueActivity.class).putExtra("id", id).putExtra("type", 1));
            getActivity().finish();
        });
        //去招采经营-需求管理-编辑界面
        binding.webViewX5.registerHandler(WebJsConstants.MANAGEMENT, (data, function) -> {
            id = new Gson().fromJson(data, TitleEntity.class).getId();
            startActivity(new Intent(getActivity(), DemandIssueActivity.class).putExtra("id", id).putExtra("type", 1));
            getActivity().finish();
        });

        //租赁-删除 点击详情删除刷新对应列表( markType:"0"机械, 1设备, 2车辆,3房产, 4土地,5工厂,6农机)
        binding.webViewX5.registerHandler(WebJsConstants.GO_BACK_LEASE_LIST, (data, function) -> {
            EventBus.getDefault().post(LeaseEvent.make().setMessageTag(EventConstant.EVENT_LEASE_PUBLISH_FILTER));
            getActivity().setResult(Activity.RESULT_OK);
            getActivity().onBackPressed();
        });

        //商品-需求大厅详情下载
        binding.webViewX5.registerHandler(WebJsConstants.GO_TO_ACCESSORY, (data, function) -> {
            AttrFileEntity3 entity = new Gson().fromJson(data, AttrFileEntity3.class);
            if (!TextUtils.isEmpty(entity.getUrl())) {
                try {
                    Uri uri = Uri.parse(entity.getUrl());
                    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                    startActivity(intent);
                } catch (Exception e) {
                }
            } else {
                MToast.showToast(getActivity(), "没有下载地址");
            }
        });
        //商品-交流询价
        binding.webViewX5.registerHandler(WebJsConstants.XUNJIA_INDEX_IM, (data, function) -> {
            //未登录
            if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                jumpLogin();
            } else {
                AttrFileEntity3 entity = new Gson().fromJson(data, AttrFileEntity3.class);
                //类型 0个人 1企业 2团队 3组织
                int TYPE = SharedPreferenceUtil.getInstance().getSaveIntData(SharedPreferenceUtil.COM_TYPE, 0);
                if (1 == TYPE) {
                    //调取接口查询IM功能
                    viewModel.enquiryImAlternate(entity.getNo());
                } else {
                    //是否个人实名认证--未实名进行实名或加入企业
                    if (!SharedPreferenceUtil.getInstance().getSaveBooleanData(SharedPreferenceUtil.PERSON_AUTH, false)) {
                        //已实名需要加入企业
                        new ThreeButtonDialog.Builder(getActivity())
                                .title("温馨提示")
                                .content("您没有权限，请认证或加入企业后再试")
                                .confirmCallback(v -> {
                                    //实名认证
                                    AuthActivity3.start(getContext());
                                }).joinCallback(v -> {
                            //去加入企业
                            JoinCompanyActivity.start(getActivity());
                        }).show();
                    } else {
                        String RELEVANCE = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.RELEVANCE, "");
                        //实名在企业中
                        if ("SUCCESS".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.ENTERPRISE_AUTH, "")) || RELEVANCE.equals("1")) {
                            new RoundDialog.Builder(getActivity())
                                    .title("温馨提示")
                                    .content("请切换到企业身份后再沟通")
                                    .cancel("我知道了")
                                    .confirm("切换身份")
                                    .singleBtn(false)
                                    .contentGravity(Gravity.CENTER)
                                    .cancelable(false)
                                    .confirmCallback(new RoundDialog.SingleCallback() {
                                        @Override
                                        public void onClick(View v) {
                                            Intent intent = new Intent();
                                            intent.putExtra("showPage", "FRAGMENT_ME");
                                            MainActivity.start(getActivity(), intent);
                                            //去跳转个人中心
                                        }
                                    })
                                    .show();
                        } else {
                            //已实名需要加入企业
                            new ThreeButtonDialog.Builder(getActivity())
                                    .title("温馨提示")
                                    .content("请认证或加入企业后再试")
                                    .confirm("认证企业")
                                    .confirmCallback(v -> {
                                        //认证企业
                                        RegisterActivity3.start(getContext());
                                    }).joinCallback(v -> {
                                //去加入企业
                                JoinCompanyActivity.start(getActivity());
                            }).show();
                        }
                    }
                }
            }
        });
        //商品-我的报价
        binding.webViewX5.registerHandler(WebJsConstants.SHOP_PRICE_DETAILS, (data, function) -> {
            //未登录
            if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                new RoundDialog.Builder(getActivity())
                        .title("温馨提示")
                        .content("请登录后再试")
                        .cancel("我知道了")
                        .confirm("去登录")
                        .singleBtn(false)
                        .contentGravity(Gravity.CENTER)
                        .cancelable(false)
                        .confirmCallback(v -> jumpLogin())
                        .show();
            } else {
                AttrFileEntity3 entity = new Gson().fromJson(data, AttrFileEntity3.class);
                if (entity.getStatus() == 4) {
                    return;
                }
                //是否个人实名认证--未实名进行实名或加入企业
                if (!SharedPreferenceUtil.getInstance().getSaveBooleanData(SharedPreferenceUtil.PERSON_AUTH, false)) {
                    //已实名需要加入企业
                    new ThreeButtonDialog.Builder(getActivity())
                            .title("温馨提示")
                            .content("您没有权限，请认证或加入企业后再试")
                            .confirmCallback(v -> {
                                //实名认证
                                AuthActivity3.start(getContext());
                            }).joinCallback(v -> {
                        //去加入企业
                        JoinCompanyActivity.start(getActivity());
                    }).show();
                } else {
                    String RELEVANCE = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.RELEVANCE, "");
                    //实名在企业中
                    if ("SUCCESS".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.ENTERPRISE_AUTH, "")) || RELEVANCE.equals("1")) {
                        //个人身份
                        if (SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.COMPANY_NAME, "").equals("")) {
                            new RoundDialog.Builder(getActivity())
                                    .title("温馨提示")
                                    .content("您没有权限，请将身份切换到企业或者加入已认证企业后再试")
                                    .cancel("我知道了")
                                    .confirm("切换身份")
                                    .singleBtn(false)
                                    .contentGravity(Gravity.CENTER)
                                    .cancelable(false)
                                    .confirmCallback(new RoundDialog.SingleCallback() {
                                        @Override
                                        public void onClick(View v) {
                                            Intent intent = new Intent();
                                            intent.putExtra("showPage", "FRAGMENT_ME");
                                            MainActivity.start(getActivity(), intent);
                                            //去跳转个人中心
                                        }
                                    })
                                    .show();
                        } else {
                            //判断是否有我的报价权限
                            if (SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.IS_DATA, "").contains("2_wodebaojia") && SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.IS_DATA, "").contains("3_shangpinfabu")) {
                                ShopPriceDetailsAct.start(getActivity(), entity.getNo());
                                SharedPreferenceUtil.getInstance().saveString("EVENT_SHOPPING_TYPE", "这是询价详情");
                                getActivity().finish();
                            } else {//无权限
                                new RoundDialog.Builder(getActivity())
                                        .title("温馨提示")
                                        .content("您没有权限，请联系管理员添加")
                                        .confirm("确定")
                                        .singleBtn(false)
                                        .contentGravity(Gravity.CENTER)
                                        .cancelable(false)
                                        .show();
                            }
                        }
                    } else {
                        //已实名需要加入企业
                        new RoundDialog.Builder(getActivity())
                                .title("温馨提示")
                                .content("您没有权限，请加入企业后再试")
                                .cancel("我知道了")
                                .confirm("去处理")
                                .singleBtn(false)
                                .contentGravity(Gravity.CENTER)
                                .cancelable(false)
                                .confirmCallback(new RoundDialog.SingleCallback() {
                                    @Override
                                    public void onClick(View v) {
                                        //去跳转个人中心
                                        Intent intent = new Intent();
                                        intent.putExtra("showPage", "FRAGMENT_ME");
                                        MainActivity.start(getActivity(), intent);
                                    }
                                })
                                .show();
                    }

                }
            }
        });

        //租赁-出租详情-点击网站 -跳转到企业界面
        binding.webViewX5.registerHandler(WebJsConstants.GO_WEBSITE, (data, function) ->

        {
            CompanyEntity entity = new Gson().fromJson(data, CompanyEntity.class);
            if ("member".equals(entity.getType())) {
                WebsiteInfoActivity.start(getActivity(), entity.getCompanyNo(), WebsiteInfoActivity.WEBSITE_FOR_COMPANY, entity.position, entity.childPosition);
            } else {
                if (!TextUtils.isEmpty(entity.getTypeVc())) {
//                    ShopInfoForCompanyTradesActivity.startAct(getActivity(), entity.getCompanyId(), entity.getCompanyNo(), 0, 0);
                    WebsiteInfoActivity.start(getActivity(), entity.getCompanyNo(), WebsiteInfoActivity.WEBSITE_FOR_COMPANY, entity.position, entity.childPosition);
                } else {
//                    ShopInfoForCompanyTradesActivity.startAct(getActivity(), entity.getCompanyId(), entity.getCompanyNo(), 1, entity.getChildPosition());
                    int websiteType = !TextUtils.isEmpty(entity.getCompanyNo()) ? WebsiteInfoActivity.WEBSITE_FOR_COMPANY : WebsiteInfoActivity.WEBSITE_FOR_PERSONAL;
                    String websiteNo = !TextUtils.isEmpty(entity.getCompanyNo()) ? entity.getCompanyNo() : entity.getUserNo();//企业no和userNo 只会存在一个
                    WebsiteInfoActivity.start(getActivity(), websiteNo, websiteType, entity.position, entity.childPosition);
                }
            }
        });

        //租赁-出租详情-点击邀请 -跳转到邀请界面
        binding.webViewX5.registerHandler(WebJsConstants.GO_INVITATION, (data, function) ->

        {
//            CompanyEntity entity = new Gson().fromJson(data, CompanyEntity.class);
//            viewModel.getCompany(entity.getCompanyNo(), entity.getType());
            /**
             * approveType  1 申请, 2 邀请
             * no （个人时传个人no，企业传企业no）
             * companyNo （个人时传个人no，企业传企业no）
             * companyName （个人时传个人Name，企业传企业Name）
             * userType 1企业，2个人
             */
            QualityMemberBean bean = new Gson().fromJson(data, QualityMemberBean.class);

            String mApproveType = "";
            if ("2".equals(bean.getApproveType())) {//邀请
                mApproveType = "inviteJoinCompany";
            } else {
                mApproveType = "applyJoinCompany";
            }

            String companyNo = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.COMPANY_NO, "");
            viewModel.getProcessStatus(companyNo, mApproveType, bean);

        });

        //租赁-我的函询详情-查看详情 -跳转到机械详情
        binding.webViewX5.registerHandler(WebJsConstants.GO_NATIVE_JIXIE, (data, function) ->

        {
            TitleEntity entity = new Gson().fromJson(data, TitleEntity.class);
            MachineOutActivity.start(getActivity(), entity.getId());
        });

        //租赁-我的函询详情-查看详情 -跳转到设备详情
        binding.webViewX5.registerHandler(WebJsConstants.GO_NATIVE_SHEBEI, (data, function) ->

        {
            TitleEntity entity = new Gson().fromJson(data, TitleEntity.class);
            DeviceDetailActivity.start(getActivity(), entity.getId());
        });

        //租赁-出租下单-机械详情下单 -跳转到填写订单界面
        binding.webViewX5.registerHandler(WebJsConstants.GO_TO_PLACE_ORDER, (data, function) ->

        {
            String id = new Gson().fromJson(data, LeaseOrderProductEntity.class).getId();
            String no = new Gson().fromJson(data, LeaseOrderProductEntity.class).getNo();
            String num = new Gson().fromJson(data, LeaseOrderProductEntity.class).getNum();
            String priceUnitNo = new Gson().fromJson(data, LeaseOrderProductEntity.class).getPriceUnitNo();
            String priceUnitName = new Gson().fromJson(data, LeaseOrderProductEntity.class).getPriceUnitName();
            String haveContract = new Gson().fromJson(data, LeaseOrderProductEntity.class).getHaveContract();
            String leaseType = new Gson().fromJson(data, LeaseOrderProductEntity.class).getLeaseType();
            String vipDriverPrice = new Gson().fromJson(data, LeaseOrderProductEntity.class).getVipDriverPrice();
            String vipDriverRatePrice = new Gson().fromJson(data, LeaseOrderProductEntity.class).getVipDriverRatePrice();
            String categoryType = new Gson().fromJson(data, LeaseOrderProductEntity.class).getCategoryType();
            //categoryType出租类型：1机械，2 设备
            if ("1".equals(categoryType)) {
                LeaseOrderMachineActivity.start(getActivity(), id, no, num, priceUnitNo, priceUnitName, haveContract, leaseType, vipDriverPrice, vipDriverRatePrice);
            } else if ("2".equals(categoryType)) {
                LeaseOrderDeviceActivity.start(getActivity(), id, no, num, priceUnitNo, priceUnitName, haveContract, leaseType, vipDriverPrice, vipDriverRatePrice);
            }
        });

        //租赁-确认接单后,需要跳转至出租订单列表页,传参 type,1为求租,2为出租
        binding.webViewX5.registerHandler(WebJsConstants.GO_TO_ORDER_LIST, (data, function) ->

        {
            String type = new Gson().fromJson(data, TitleEntity.class).getType();
            if ("1".equals(type)) {
                SelfLeaseOrderListActivity.start(getActivity(), "1");
            } else if ("2".equals(type)) {
                SelfLeaseOrderListActivity.start(getActivity(), "2");
            }
            EventBus.getDefault().postSticky(LeaseOrderEvent.make());
        });
        //租赁-申请付款
        binding.webViewX5.registerHandler(WebJsConstants.GO_APPLY_FOR_PAYMENT, (data, function) ->

        {
            LeaseOrderPaymentEntity entity = new Gson().fromJson(data, LeaseOrderPaymentEntity.class);
            LeaseOrderPaymentActivity.start(getActivity(), entity);
        });

        //租赁-申请确认
        binding.webViewX5.registerHandler(WebJsConstants.GO_APPLICATION_CONFIRMATION, (data, function) ->
        {
            String orderNo = new Gson().fromJson(data, LeaseOrderPaymentEntity.class).getOrderNo();
            String orderType = new Gson().fromJson(data, LeaseOrderReceiveEntity.class).getOrderType();//租赁类型:1机械，2 设备
            LeaseOrderConfirmActivity.start(getActivity(), orderNo, orderType);
        });

        //租赁-申请接单
        binding.webViewX5.registerHandler(WebJsConstants.GO_RENT_IN_APPLICATION_CONFIRMATION, (data, function) ->

        {
            String orderNo = new Gson().fromJson(data, LeaseOrderReceiveEntity.class).getOrderNo();
            String rentalTotalPrice = new Gson().fromJson(data, LeaseOrderReceiveEntity.class).getRentalTotalPrice();//原价
            String newRentalPrice = new Gson().fromJson(data, LeaseOrderReceiveEntity.class).getNewRentalPrice();//改价后的价格
            String transportPrice = new Gson().fromJson(data, LeaseOrderReceiveEntity.class).getTransportPrice();//运费
            String newDriverProvider = new Gson().fromJson(data, LeaseOrderReceiveEntity.class).getNewDriverProvider();//(改价)是否提供驾驶员 1求租方（不含） 2 出租方（含）
            String newNeedInvoice = new Gson().fromJson(data, LeaseOrderReceiveEntity.class).getNewNeedInvoice();//(改价)是否含税,0否，1是
            String orderType = new Gson().fromJson(data, LeaseOrderReceiveEntity.class).getOrderType();//租赁类型:1机械，2 设备
            LeaseOrderReceiveActivity.start(getActivity(), orderNo, rentalTotalPrice, transportPrice, newRentalPrice, newDriverProvider, newNeedInvoice, orderType);
        });

        //租赁-开通我的钱包
        binding.webViewX5.registerHandler(WebJsConstants.GO_OPEN_WALLET, (data, function) ->

        {
            try {
                //isPersonal   true 为个人 false 为企业
                JSONObject jsonObject = new JSONObject(data);
                boolean isPersonal = jsonObject.getBoolean("isPersonal");
                OpenAccountFirstActivity.start(getActivity(), isPersonal);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        });

        //租赁-支付
        binding.webViewX5.registerHandler(WebJsConstants.GO_IMMEDIDATE_PAYMENT, (data, function) ->

        {
            try {
                JSONObject jsonObject = new JSONObject(data);
                String orderId = jsonObject.getString("orderId");
                PersonPayActivity.start(getActivity(), orderId);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        });

        //租赁-复制
        binding.webViewX5.registerHandler(WebJsConstants.GO_CLICK_COPY, (data, function) ->
        {
            try {
                JSONObject jsonObject = new JSONObject(data);
                //获取剪贴板管理器：
                ClipboardManager cm = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
                // 创建普通字符型ClipData
                ClipData mClipData = ClipData.newPlainText("Label", jsonObject.getString("text"));
                // 将ClipData内容放到系统剪贴板里。
                cm.setPrimaryClip(mClipData);
                MToast.showToast(getActivity(), "复制成功！");
            } catch (JSONException e) {
                e.printStackTrace();
            }

        });

        //租赁-保存图片
        binding.webViewX5.registerHandler(WebJsConstants.GO_SAVE_PICTURE, (data, function) ->
        {
            try {
                DialogHelper.showProgressDialog(getActivity(), "保存中...").setCanceledOnTouchOutside(false);
                JSONObject jsonObject = new JSONObject(data);
                String name = jsonObject.getString("name");
                String url = jsonObject.getString("url");

                Glide.with(this)
                        .asBitmap()
                        .load(url)
                        .into(new CustomTarget<Bitmap>() {
                            @Override
                            public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
                                viewModel.saveImageToGallery(resource, name + ".jpeg");
                                DialogHelper.dismissProgressDialog();
                            }

                            @Override
                            public void onLoadCleared(@Nullable Drawable placeholder) {
                                DialogHelper.dismissProgressDialog();
                            }
                        });

            } catch (JSONException e) {
                e.printStackTrace();
            }

        });

        //需求大厅认证
        binding.webViewX5.registerHandler(WebJsConstants.COMPANYAPPROVE, (data, function) ->

        {
            AuthActivity3.start(getContext());
        });
        //货主订单删除
        binding.webViewX5.registerHandler(WebJsConstants.OWNER_DEL_Order, (data, function) ->

        {
            String orderNo = new Gson().fromJson(data, TitleEntity.class).getOrderNo();
            showDialog("删除确认", "确定删除吗？？？", 2, orderNo);
        });
        //货主订单确认
        binding.webViewX5.registerHandler(WebJsConstants.OWNER_CONFIRM_ORDER, (data, function) ->

        {
            String orderNo = new Gson().fromJson(data, TitleEntity.class).getOrderNo();
            showDialog("订单确认", "订单确认后车主可进行发车操作", 0, orderNo);
        });
        //货主订单取消
        binding.webViewX5.registerHandler(WebJsConstants.OWNER_CANCEL_ORDER, (data, function) ->

        {
            String orderNo = new Gson().fromJson(data, TitleEntity.class).getOrderNo();
            showDialog("取消确认", "确定取消订单吗？？？", 1, orderNo);
        });
        //车主取消
        binding.webViewX5.registerHandler(WebJsConstants.OWNER_CANCE_LLATION, (data, function) ->

        {
            String orderNo = new Gson().fromJson(data, TitleEntity.class).getOrderNo();
            showDialog("取消确认", "确定取消订单吗？？？", 1, orderNo);
        });
        //车主发车
        binding.webViewX5.registerHandler(WebJsConstants.OWNER_DEPARTAURE, (data, function) ->

        {
            String orderNo = new Gson().fromJson(data, TitleEntity.class).getOrderNo();
            showDialog("发车确认", " 确定发车吗？", 3, orderNo);

        });
        //车主到达
        binding.webViewX5.registerHandler(WebJsConstants.OWNER_ARRIVAL, (data, function) ->

        {
            String orderNo = new Gson().fromJson(data, TitleEntity.class).getOrderNo();
            showDialog("到达确认", " 确定到达吗？", 4, orderNo);
        });
        //集采——需方发起，去加盟集采或参与报价页面
        binding.webViewX5.registerHandler(WebJsConstants.GO_TO_OFFER_OR_JOIN, (data, function) ->
        {
            String no = new Gson().fromJson(data, TitleEntity.class).getNo();
            String type = new Gson().fromJson(data, TitleEntity.class).getType();
            String jId = new Gson().fromJson(data, TitleEntity.class).getjId();
            String groupBuyType = new Gson().fromJson(data, TitleEntity.class).getGroupBuyType();
            int offerJoin = new Gson().fromJson(data, TitleEntity.class).getOfferJoin();//1是首次,2是再次
            if ("0".equals(type)) {//0是参与加盟、1是参与报价
                JoinInJiCaiActivity.start(getContext(), no, null, jId, 1, groupBuyType, historyUrl);//可多次加盟，都走第一次
                getActivity().finish();
            } else {
                JiCaiQuotedPriceActivity.start(getContext(), no, jId, offerJoin, groupBuyType, historyUrl);
                getActivity().finish();
            }
        });
        //集采——厂家集采，去立即参与页面
        binding.webViewX5.registerHandler(WebJsConstants.GO_GET_INVOLVED_NOW, (data, function) ->

        {
            String no = new Gson().fromJson(data, TitleEntity.class).getNo();
            FactoryParticipationActivity.start(getContext(), no, historyUrl);
            getActivity().finish();
        });
        //编辑工队工人基础信息
        binding.webViewX5.registerHandler(WebJsConstants.GO_EDIT_INFO, (data, function) ->

        {
            SelfBasicInformationActivity.start(getActivity());
        });
        //新增工队工人工作经验
        binding.webViewX5.registerHandler(WebJsConstants.GO_ADD_Worker, (data, function) ->

        {
            SelfWorkExperienceActivity.start(getActivity(), 0, -1);
        });
        //新增工队工人资格证书
        binding.webViewX5.registerHandler(WebJsConstants.GO_ADD_File, (data, function) ->

        {
            SelfWorkExperienceActivity.start(getActivity(), 1, -1);
        });
        //编辑工队工人工作经验
        binding.webViewX5.registerHandler(WebJsConstants.GO_EDIT_WORKER, (data, function) ->

        {
            int index = new Gson().fromJson(data, TitleEntity.class).getIdx();
            SelfWorkExperienceActivity.start(getActivity(), 0, index);
        });
        //编辑工队工人资格证书
        binding.webViewX5.registerHandler(WebJsConstants.GO_EDIT_FILE, (data, function) ->

        {
            int index = new Gson().fromJson(data, TitleEntity.class).getIdx();
            SelfWorkExperienceActivity.start(getActivity(), 1, index);
        });
        //待办审批详情操作按钮后返回待办列表
        binding.webViewX5.registerHandler(WebJsConstants.BACK_TO_DO_LIST, (data, function) ->

        {
            EventBus.getDefault().postSticky(WebEvent.make().setMessageTag(EventConstant.EVENT_APPROVAL_REFRESH));
            getActivity().finish();
        });


        //申请信息页面
        binding.webViewX5.registerHandler(WebJsConstants.GO_APPLY_INFO, (data, function) -> {
            Log.i("xxx", new Gson().toJson(data));
            QualityMemberBean2 memberBean = new Gson().fromJson(data, QualityMemberBean2.class);

            QualityMemberBean bean = new QualityMemberBean();
            bean.setId(memberBean.getId() + "");
            bean.setNo(memberBean.getNo());
            bean.setCompanyNo(memberBean.getRelieveBusinessNo());
            bean.setCompanyName(memberBean.getRelieveBusinessName());
            bean.setMemberRelation(memberBean.getRelation());
            bean.setApproveType(memberBean.getApproveType() + "");
            bean.setUserType(memberBean.getRelieveType());
            bean.setStatus(memberBean.getStatus());

//            QualityMemberBean memberBean = new Gson().fromJson(data, QualityMemberBean.class);
            String mApproveType = "";
            if (memberBean.getApproveType() == 2) {//邀请
                mApproveType = "inviteJoinCompany";
            } else {
                mApproveType = "applyJoinCompany";
            }
            String companyNo = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.COMPANY_NO, "");
            viewModel.getProcessStatus(companyNo, mApproveType, bean);


//            QualityMemberBean memberBean = new Gson().fromJson(data, QualityMemberBean.class);
//            if (memberBean != null) {
//                memberBean.setCompanyNo(memberBean.getNo());
//                //跳转到申请加盟界面// 审批类型 1 申请加盟(固定传1就行) 2邀请加盟
//                if (memberBean.getApproveType().equals("1")) {
//                    MemberApplyJoinActivity.startAgain(getActivity(), memberBean, true);
//                } else if (memberBean.getApproveType().equals("2")) {
//                    MemberInviteJoinActivity.startAgain(getActivity(), memberBean, true);
//                }
//            }
        });

        //申请审批信息页面
        binding.webViewX5.registerHandler(WebJsConstants.GO_APPLY_APPROVAL_INFO, (data, function) ->

        {
            QualityMemberBean memberBean = new Gson().fromJson(data, QualityMemberBean.class);
            if (memberBean != null) {
                // joinWay; //加盟方式  1申请 2邀请
                if (memberBean.getApproveType().equals("1")) {
                    MemberApplyJoinActivity.startAgain(getActivity(), memberBean, true);
                } else if (memberBean.getApproveType().equals("2")) {
                    MemberInviteJoinActivity.startAgain(getActivity(), memberBean, true);
                }
            }
        });
        // 申请记录页面
        binding.webViewX5.registerHandler(WebJsConstants.GO_APPLY_RECORD, (data, function) ->

        {
            MemberInviteOrApplyActivity.startInviteOrApplyRecord(getActivity(), 1);
        });
        // 邀请记录页面
        binding.webViewX5.registerHandler(WebJsConstants.GO_INVITE_RECORD, (data, function) ->

        {
            MemberInviteOrApplyActivity.startInviteOrApplyRecord(getActivity(), 0);
        });
        // 跳转会员类型
        binding.webViewX5.registerHandler(WebJsConstants.GO_MEMBER_TYPE, (data, function) -> {
            MemberBean memberBean = new Gson().fromJson(data, MemberBean.class);
            if (memberBean != null) {
                String relation = memberBean.getMemberUpdateLeverType();
                // memberUpdateLeverType :  //1供方会员 2需方会员
                if (TextUtils.equals("1", relation)) {
                    // ascription 0 供方 1需方
                    ChooseMemberTypeActivity.start(getActivity(), memberTypes, "0", REQ_MEMBER_TYPE_CODE);
                } else {
                    ChooseMemberTypeActivity.start(getActivity(), memberTypes, "1", REQ_MEMBER_TYPE_CODE);
                }
            }
        });

        //工队编辑
        binding.webViewX5.registerHandler(WebJsConstants.GO_Team_Edit, (data, function) ->
        {
            Log.e(TAG, "工队编辑H5返回数据" + data + " --- " + data.toString());
            FindPackersEntity findPackersEntity = new Gson().fromJson(data, FindPackersEntity.class);
            Log.e(TAG, "工队编辑H5跳转: " + findPackersEntity.getTeamType() + " --- " + findPackersEntity.getNo());
            Intent intent = new Intent(getActivity(), SelfTeamIntroduceActivity.class);
            intent.putExtra("teamType", String.valueOf(findPackersEntity.getTeamType()));
            intent.putExtra("no", findPackersEntity.getNo());
            intent.putExtra("type", "webH5");
            startActivity(intent);
            getActivity().finish();
        });
        //工队业绩
        binding.webViewX5.registerHandler(WebJsConstants.GO_Team_Performance, (data, function) ->

        {
            if (!TextUtils.isEmpty(data)) {
                FindPackersEntity findPackersEntity = new Gson().fromJson(data, FindPackersEntity.class);
                if (findPackersEntity != null && !TextUtils.isEmpty(findPackersEntity.getNo())) {
                    //选择工队业绩
                    WorkPerformanceActivity.start(getActivity(), findPackersEntity.getNo());
                    getActivity().finish();
                } else {
                    Log.e(TAG, "工队业绩解析参数有误！");
                }

            } else {
                Log.e(TAG, "工队业绩H5返回数据有误！");
            }
        });
        //工队人员
        binding.webViewX5.registerHandler(WebJsConstants.GO_Team_Personnel, (data, function) ->
        {
            if (!TextUtils.isEmpty(data)) {
                FindPackersEntity findPackersEntity = new Gson().fromJson(data, FindPackersEntity.class);
                if (findPackersEntity != null && !TextUtils.isEmpty(findPackersEntity.getNo())) {
                    //选择工队人员
                    WorkPersonnelActivity.start(getActivity(), findPackersEntity.getNo());
                    getActivity().finish();
                } else {
                    Log.e(TAG, "工队人员解析参数有误！");
                }

            } else {
                Log.e(TAG, "工队人员H5返回数据有误！");
            }
        });
        //工队设备
        binding.webViewX5.registerHandler(WebJsConstants.GO_Team_Equipment, (data, function) ->

        {
            if (!TextUtils.isEmpty(data)) {
                FindPackersEntity findPackersEntity = new Gson().fromJson(data, FindPackersEntity.class);
                if (findPackersEntity != null && !TextUtils.isEmpty(findPackersEntity.getNo())) {
                    //选择工队设备
                    WorkEquipmentActivity.start(getActivity(), findPackersEntity.getNo());
                    getActivity().finish();
                } else {
                    Log.e(TAG, "工队设备解析参数有误！");
                }

            } else {
                Log.e(TAG, "工队设备H5返回数据有误！");
            }
        });
        // 网站发布返回
        binding.webViewX5.registerHandler(WebJsConstants.GO_Quill_Editor_BackAction, (data, function) -> {
            String body = new Gson().fromJson(data, TitleEntity.class).getText();
            Intent intent = new Intent();
            intent.putExtra("body", body);
            getActivity().setResult(WebsiteUpDataJYDTActivity.RESULT_CODE_SELECT, intent);
            goBack();
        });
        binding.webViewX5.registerHandler(WebJsConstants.GO_user_CenterEdit, (data, function) -> {
            String id = new Gson().fromJson(data, TitleEntity.class).getId();
            String markType = new Gson().fromJson(data, TitleEntity.class).getMarkType();
            goToEdit(id, markType);
        });
        // js 回调 java获取入参
        binding.webViewX5.registerHandler(WebJsConstants.GO_Get_Quill_Detail, (data, function) -> {
            String text = getH5Text().trim();
            function.onCallBack(text);
        });

        binding.webViewX5.registerHandler(WebJsConstants.GO_ATTENTION, (data, function) -> {
            Log.e(TAG, "initWebViewBridge: " + data);
            String mUserNo = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.USER_NO, "");
            int companyType = SharedPreferenceUtil.getInstance().getSaveIntData(SharedPreferenceUtil.COM_TYPE, 0);
            if (!"".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                List<Pair<String, Object>> list = GsonUtil.json2Pair(data, "isAttention", "no", "type", "userNo");
                if (list.size() > 0) {
                    if (companyType == 0 || companyType == 1) {
                        if (list.get(3) != null && list.get(3).second != null && !(list.get(3).second).equals(mUserNo)) {
                            viewModel.followForTeam((String) list.get(1).second, String.valueOf(list.get(2).second), !(boolean) list.get(0).second);
                        } else {
                            MToast.showToast(getContext(), "不能关注自己发布的工队");
                        }
                    } else {
                        MToast.showToast(getContext(), "请前往用户中心将身份切换为个人或企业才能关注");
                    }
                }
            } else {
                jumpLogin();
            }
        });

        //所有模块h5跳转网站协议
        binding.webViewX5.registerHandler(WebJsConstants.GO_TO_WEBSITE, ((data, function) -> {
            try {
                WebsiteEntity entity = new Gson().fromJson(data, WebsiteEntity.class);
                if (TextUtils.isEmpty(entity.siteNo)) {
                    MToast.showToast(getContext(), "网站编号为空");
                    return;
                }
                WebsiteInfoActivity.start(getContext(), entity.siteNo, entity.siteType);
            } catch (Exception e) {
                MLog.d("website", "H5传参错误");
            }
        }));
        //企业专项---再次邀请
        binding.webViewX5.registerHandler(WebJsConstants.INVITE_AGAIN, ((data, function) -> {
            try {
                com.sgb.kjwl.model.entity.manage.special.CompanyEntity entity = new Gson().fromJson(data, com.sgb.kjwl.model.entity.manage.special.CompanyEntity.class);
                ;
                if (entity != null) {
                    InviteMemberPostActivity.Companion.launch(getContext(), entity, false);
                }
            } catch (Exception e) {
                MLog.d("website", "H5传参错误");
            }
        }));

        //企业专项---受理状态改变
        binding.webViewX5.registerHandler(WebJsConstants.CURRENT_UPDATE_STATUS_CHANGE, ((data, function) -> {
            try {
                TelEntity entity = new Gson().fromJson(data, TelEntity.class);
                mAcceptanceRefresh = entity.isUpdate;
            } catch (Exception e) {
                MLog.d("website", "H5传参错误");
            }
        }));

        //去再次邀请
        binding.webViewX5.registerHandler(WebJsConstants.GO_REFUSE_APPROVE, (data, function) -> {
            String id = new Gson().fromJson(data, TitleEntity.class).getId();
            String type = new Gson().fromJson(data, TitleEntity.class).getType();
            String Invitedtitle = new Gson().fromJson(data, TitleEntity.class).getInvitedtime();
            String Invitedtime = new Gson().fromJson(data, TitleEntity.class).getInvitedtitle();
            String fromWhere = "";
            if ("zhaobiao".equals(type)) {
                fromWhere = "1";
            } else if ("jingjia".equals(type)) {
                fromWhere = "2";
            }
            PickInvitedApplyDetailsActivity.start(getActivity(), fromWhere, Invitedtitle, Invitedtime
                    , 1, null, id, null, null, null, 0, "");
        });

        //去个人，企业选择页面
        binding.webViewX5.registerHandler(WebJsConstants.GET_DELAY, (data, function) -> {
            TitleEntity titleEntity = new Gson().fromJson(data, TitleEntity.class);
            String type = titleEntity.getType();
            String fromWhere = "";
            if ("zhaobiao".equals(type)) {
                fromWhere = "1";
            } else if ("jingjia".equals(type)) {
                fromWhere = "2";
            }
            /*
             * ：id :详情页id  ,  Invitedtitle：标的名称 ，type: 区分招标竞价 “zhaobiao" "jingjia", biddingUserIdentity: , biddingUserSign, applyEndTime memberLevel，biddingRegion
             * */
            PickInvitedApply invitedApply = new PickInvitedApply();
            invitedApply.setId(titleEntity.getId());
            invitedApply.setName(titleEntity.getInvitedtitle());
            if (!TextUtils.isEmpty(titleEntity.getBiddingUserIdentity())) {
                invitedApply.setBiddingUserIdentity(titleEntity.getBiddingUserIdentity());
            } else {
                invitedApply.setBiddingUserIdentity("");
            }
            if (titleEntity.getBiddingUserSign() != null && titleEntity.getBiddingUserSign().size() > 0) {
                invitedApply.setBiddingUserSign(titleEntity.getBiddingUserSign());
            } else {
                invitedApply.setBiddingUserSign(new ArrayList<>());
            }
            if (!TextUtils.isEmpty(titleEntity.getApplyEndTime())) {
                invitedApply.setApplyEndTime(titleEntity.getApplyEndTime());
            } else {
                invitedApply.setApplyEndTime("");
            }
            if (!TextUtils.isEmpty(titleEntity.getMemberLevel())) {
                invitedApply.setMemberLevel(titleEntity.getMemberLevel());
            } else {
                invitedApply.setMemberLevel("");
            }
            if (titleEntity.getBiddingRegion() != null && titleEntity.getBiddingRegion().size() > 0) {
                invitedApply.setBiddingRegion(titleEntity.getBiddingRegion());
            } else {
                invitedApply.setBiddingRegion(new ArrayList<>());
            }
            PickInvitedSignUpActivity.start(getContext(), invitedApply, fromWhere);
        });
        //需求预告-需求报价
        binding.webViewX5.registerHandler(WebJsConstants.GO_OFFER, (data, function) -> {
            TitleEntity titleEntity = new Gson().fromJson(data, TitleEntity.class);
            PickUtil.startDemandOffer(getContext(), titleEntity.getId(), titleEntity.getType(), "", "2");
            getActivity().finish();
        });

        //招采-预览图片下载图片方法
        binding.webViewX5.registerHandler(WebJsConstants.ZC_IMGDOWNLOAD, (data, function) -> {
            TitleEntity titleEntity = new Gson().fromJson(data, TitleEntity.class);
            if (!TextUtils.isEmpty(titleEntity.getUrl())) {
                DownloadImageData(titleEntity.getUrl());
            }
        });

        //导航
        binding.webViewX5.registerHandler(WebJsConstants.GO_SHOP_MAP, (data, function) -> {
            //导航弹窗初始化
            if (mNavigationDialog == null)
                mNavigationDialog = new MapNavigationDialog(getActivity());
            String lat = new Gson().fromJson(data, TitleEntity.class).getLat();
            String lng = new Gson().fromJson(data, TitleEntity.class).getLng();
            String address = new Gson().fromJson(data, TitleEntity.class).getAddress();
            AddressItem item = new AddressItem(Double.valueOf(lat), Double.valueOf(lng), address);
            mNavigationDialog.navigation(item);
        });
    }

    //下载图片
    private void DownloadImageData(String url) {
        //执行下载图片方法
        DownloadManager mDownloadManager = DownloadManager.getInstance();
        String fileName = mDownloadManager.getFileName(url);
        String galleryPath = Environment.getExternalStorageDirectory()
                + File.separator + Environment.DIRECTORY_DCIM
                + File.separator + "Camera" + File.separator;
        mDownloadManager.add(url, galleryPath, fileName, new DownloadListner() {
            @Override
            public void onFinished() { //下载完成
                onFinishedData(galleryPath, fileName);
            }

            @Override
            public void onProgress(float progress, boolean isDownloading) { //更新中
                MLog.e("自动更新", "更新中" + progress);
            }

            @Override
            public void onPause() { //暂停
                MLog.e("自动更新", "暂停了");
            }

            @Override
            public void onCancel() { //取消
                MLog.e("自动更新", "下载已取消");
            }
        });
        mDownloadManager.download(url); //开始下载
    }

    private void onFinishedData(String galleryPath, String fileName) {
        ThreadUtils.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                MToast.showToast(getActivity(), "下载成功！");
                getActivity().sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + galleryPath + "/" + fileName)));
            }
        });
    }

    /**
     * 跳转原生编辑界面
     *
     * @param markType "1"经营业绩,2"专项资质,"3"经营动态,"5"荣誉荣耀,6"商标详情,"7"专利详情,"8"版权详情,
     */
    private void goToEdit(String id, String markType) {
        this.isEdt = true;
        switch (markType) {
            case "1"://经营业绩
                WebsiteUpDataJingYingYeJiActivity.start(getActivity(), id);
                break;
            case "2"://专项资质
                WebsiteUpDataZhuanXiangZiZhiActivity.start(getActivity(), "资质", id);
                break;
            case "3": //经营动态
                WebsiteUpDataJYDTActivity.start(getActivity(), "经营", id);
                break;
            case "5"://荣誉荣耀
                WebsiteUpDataRongYuRongYaoActivity.start(getActivity(), "荣誉", id);
                break;
            case "6"://商标详情
                WebsiteUpDataZhiShiChanQuanActivity.start(getActivity(), "商标", id);
                break;
            case "7"://专利详情
                WebsiteUpDataZhiShiChanQuanActivity.start(getActivity(), "专利", id);
                break;
            case "8"://版权详情
                WebsiteUpDataZhiShiChanQuanActivity.start(getActivity(), "版权", id);
                break;
        }
    }

    @SuppressLint("SetTextI18n")
    private void jsGetToken() {
        binding.webViewX5.callHandler(WebJsConstants.RECV_TOKEN, new Gson().toJson(getMapToken()), data -> {
        });
        binding.webViewX5.callHandler(WebJsConstants.SEND_TITLE, new Gson().toJson(getMapToken()), new CallBackFunction() {
            @Override
            public void onCallBack(String data) {
                Log.d("SEND_TITLE", "callHandler data : " + data);
            }
        });
    }

    private String getH5Text() {
        String text = "";
        if (getActivity() != null && getActivity().getIntent() != null && getActivity().getIntent().getStringExtra(TEXT) != null) {
            if (!TextUtils.isEmpty(getActivity().getIntent().getStringExtra(TEXT))) {
                text = getActivity().getIntent().getStringExtra(TEXT);
            }
        }
        return text;
    }

    public void setTitle(String title) {
        binding.include.titleView.setText(title);
    }

    public void setFollowStatus(boolean b) {
        binding.webViewX5.callHandler(WebJsConstants.GET_ATTENTION, GsonUtil.pair2Json(Pair.create("type", b ? 1 : 0)), new CallBackFunction() {
            @Override
            public void onCallBack(String data) {

            }
        });
    }

    public class TitleEntity implements Serializable {
        String id;
        String title;
        String type;
        String text;
        String freight;
        String updateTime;
        String createUserNo;
        String createCompanyNo;
        String quoteUtil;
        String markType;//租赁类型
        String inquiryUserMemberNo;
        String imAccount;
        String supplierId;//店铺id
        String no;
        String jId;
        String negotiable;//1为面议
        int idx;
        String groupBuyType;
        int offerJoin;
        String companyNo;
        boolean hasApply;// 租赁-是否展示右侧审批日志,有并且为true为展示
        String url;//租赁-审批日志url
        String userNo;
        boolean showShare; //是否显示竞价分享按钮 true显示
        String weixinFenXiangMsg;   //竞价分享的文本
        String weixinFenXiangUrl;   //竞价分享的URL地址
        String companyName;     //竞价采购企业
        String BidType;    //竞价,招标类型
        String budgetPrice;   //概算金额
        String addrDetail;   //项目地址
        String itemBusinessControlAmount;   //工程量
        String projectPrice;   //项目造价
        String name;   //项目造价
        String biddingUserIdentity;
        String applyEndTime;
        String memberLevel;
        String image;
        String address;
        String currentPrice;
        int version;
        List<String> biddingRegion;
        List<Integer> biddingUserSign;

        public int getVersion() {
            return version;
        }

        public void setVersion(int version) {
            this.version = version;
        }

        public String getAddress() {
            return address;
        }

        public void setAddress(String address) {
            this.address = address;
        }

        public String getCurrentPrice() {
            return currentPrice;
        }

        public void setCurrentPrice(String currentPrice) {
            this.currentPrice = currentPrice;
        }

        public String getImage() {
            return image;
        }

        public void setImage(String image) {
            this.image = image;
        }

        public String getBiddingUserIdentity() {
            return biddingUserIdentity;
        }

        public void setBiddingUserIdentity(String biddingUserIdentity) {
            this.biddingUserIdentity = biddingUserIdentity;
        }

        public String getApplyEndTime() {
            return applyEndTime;
        }

        public void setApplyEndTime(String applyEndTime) {
            this.applyEndTime = applyEndTime;
        }

        public String getMemberLevel() {
            return memberLevel;
        }

        public void setMemberLevel(String memberLevel) {
            this.memberLevel = memberLevel;
        }

        public List<String> getBiddingRegion() {
            return biddingRegion;
        }

        public void setBiddingRegion(List<String> biddingRegion) {
            this.biddingRegion = biddingRegion;
        }

        public List<Integer> getBiddingUserSign() {
            return biddingUserSign;
        }

        public void setBiddingUserSign(List<Integer> biddingUserSign) {
            this.biddingUserSign = biddingUserSign;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getProjectPrice() {
            return projectPrice;
        }

        public void setProjectPrice(String projectPrice) {
            this.projectPrice = projectPrice;
        }

        public String getAddrDetail() {
            return addrDetail;
        }

        public void setAddrDetail(String addrDetail) {
            this.addrDetail = addrDetail;
        }

        public String getItemBusinessControlAmount() {
            return itemBusinessControlAmount;
        }

        public void setItemBusinessControlAmount(String itemBusinessControlAmount) {
            this.itemBusinessControlAmount = itemBusinessControlAmount;
        }

        int state;     //招标状态
        int num;     //1是申请,2是正常
        int value;    //value == verticalTypeValue
        String Invitedtitle;
        String Invitedtime;

        public String getInvitedtitle() {
            return Invitedtitle;
        }

        public void setInvitedtitle(String invitedtitle) {
            Invitedtitle = invitedtitle;
        }

        public String getInvitedtime() {
            return Invitedtime;
        }

        public void setInvitedtime(String invitedtime) {
            Invitedtime = invitedtime;
        }

        public int getState() {
            return state;
        }

        public void setState(int state) {
            this.state = state;
        }

        public int getNum() {
            return num;
        }

        public void setNum(int num) {
            this.num = num;
        }

        public int getValue() {
            return value;
        }

        public void setValue(int value) {
            this.value = value;
        }

        public String getCompanyName() {
            return companyName;
        }

        public void setCompanyName(String companyName) {
            this.companyName = companyName;
        }

        public String getBidType() {
            return BidType;
        }

        public void setBidType(String bidType) {
            BidType = bidType;
        }

        public String getBudgetPrice() {
            return budgetPrice;
        }

        public void setBudgetPrice(String budgetPrice) {
            this.budgetPrice = budgetPrice;
        }

        public boolean isShowShare() {
            return showShare;
        }

        public void setShowShare(boolean showShare) {
            this.showShare = showShare;
        }

        public String getWeixinFenXiangMsg() {
            return weixinFenXiangMsg;
        }

        public void setWeixinFenXiangMsg(String weixinFenXiangMsg) {
            this.weixinFenXiangMsg = weixinFenXiangMsg;
        }

        public String getWeixinFenXiangUrl() {
            return weixinFenXiangUrl;
        }

        public void setWeixinFenXiangUrl(String weixinFenXiangUrl) {
            this.weixinFenXiangUrl = weixinFenXiangUrl;
        }

        public String getUserNo() {
            return userNo;
        }

        public void setUserNo(String userNo) {
            this.userNo = userNo;
        }

        public boolean isHasApply() {
            return hasApply;
        }

        public void setHasApply(boolean hasApply) {
            this.hasApply = hasApply;
        }

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }

        public int getIdx() {
            return idx;
        }

        public void setIdx(int idx) {
            this.idx = idx;
        }

        int focusFlag;

        public int getFocusFlag() {
            return focusFlag;
        }

        public void setFocusFlag(int focusFlag) {
            this.focusFlag = focusFlag;
        }

        public String getInquiryUserMemberNo() {
            return inquiryUserMemberNo;
        }

        public void setInquiryUserMemberNo(String inquiryUserMemberNo) {
            this.inquiryUserMemberNo = inquiryUserMemberNo;
        }

        public String getText() {
            return text;
        }

        public void setText(String text) {
            this.text = text;
        }

        String telephone;
        String orderNo;
        String lat;
        String lng;
        String bidtype;

        public String getBidtype() {
            return bidtype;
        }

        public void setBidtype(String bidtype) {
            this.bidtype = bidtype;
        }

        public String getLat() {
            return lat;
        }

        public void setLat(String lat) {
            this.lat = lat;
        }

        public String getLng() {
            return lng;
        }

        public void setLng(String lng) {
            this.lng = lng;
        }

        public String getOrderNo() {
            return orderNo;
        }

        public void setOrderNo(String orderNo) {
            this.orderNo = orderNo;
        }

        public String getTelephone() {
            return telephone;
        }

        public void setTelephone(String telephone) {
            this.telephone = telephone;
        }

        public String getMarkType() {
            return markType;
        }

        public void setMarkType(String markType) {
            this.markType = markType;
        }

        public String getUpdateTime() {
            return updateTime;
        }

        public void setUpdateTime(String updateTime) {
            this.updateTime = updateTime;
        }

        public String getCreateUserNo() {
            return createUserNo;
        }

        public void setCreateUserNo(String createUserNo) {
            this.createUserNo = createUserNo;
        }

        public String getCreateCompanyNo() {
            return createCompanyNo;
        }

        public void setCreateCompanyNo(String createCompanyNo) {
            this.createCompanyNo = createCompanyNo;
        }

        public String getQuoteUtil() {
            return quoteUtil;
        }

        public void setQuoteUtil(String quoteUtil) {
            this.quoteUtil = quoteUtil;
        }

        public String getFreight() {
            return freight;
        }

        public void setFreight(String freight) {
            this.freight = freight;
        }

        public String getType() {
            return TextUtils.isEmpty(type) ? "" : type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getSupplierId() {
            return supplierId;
        }

        public void setSupplierId(String supplierId) {
            this.supplierId = supplierId;
        }

        public String getImAccount() {
            return imAccount;
        }

        public void setImAccount(String imAccount) {
            this.imAccount = imAccount;
        }

        public String getNo() {
            return no;
        }

        public void setNo(String no) {
            this.no = no;
        }

        public String getjId() {
            return jId;
        }

        public void setjId(String jId) {
            this.jId = jId;
        }

        public String getNegotiable() {
            return negotiable;
        }

        public void setNegotiable(String negotiable) {
            this.negotiable = negotiable;
        }

        public String getGroupBuyType() {
            return groupBuyType;
        }

        public void setGroupBuyType(String groupBuyType) {
            this.groupBuyType = groupBuyType;
        }

        public int getOfferJoin() {
            return offerJoin;
        }

        public void setOfferJoin(int offerJoin) {
            this.offerJoin = offerJoin;
        }

        public String getCompanyNo() {
            return companyNo;
        }

        public void setCompanyNo(String companyNo) {
            this.companyNo = companyNo;
        }

        @Override
        public String toString() {
            return "TitleEntity{" +
                    "id='" + id + '\'' +
                    ", title='" + title + '\'' +
                    ", type='" + type + '\'' +
                    ", text='" + text + '\'' +
                    ", freight='" + freight + '\'' +
                    ", updateTime='" + updateTime + '\'' +
                    ", createUserNo='" + createUserNo + '\'' +
                    ", createCompanyNo='" + createCompanyNo + '\'' +
                    ", quoteUtil='" + quoteUtil + '\'' +
                    ", markType='" + markType + '\'' +
                    ", inquiryUserMemberNo='" + inquiryUserMemberNo + '\'' +
                    ", imAccount='" + imAccount + '\'' +
                    ", supplierId='" + supplierId + '\'' +
                    ", no='" + no + '\'' +
                    ", jId='" + jId + '\'' +
                    ", negotiable='" + negotiable + '\'' +
                    ", idx=" + idx +
                    ", groupBuyType='" + groupBuyType + '\'' +
                    ", offerJoin=" + offerJoin +
                    ", companyNo='" + companyNo + '\'' +
                    ", hasApply=" + hasApply +
                    ", url='" + url + '\'' +
                    ", userNo='" + userNo + '\'' +
                    ", showShare=" + showShare +
                    ", weixinFenXiangMsg='" + weixinFenXiangMsg + '\'' +
                    ", weixinFenXiangUrl='" + weixinFenXiangUrl + '\'' +
                    ", companyName='" + companyName + '\'' +
                    ", BidType='" + BidType + '\'' +
                    ", budgetPrice='" + budgetPrice + '\'' +
                    ", addrDetail='" + addrDetail + '\'' +
                    ", itemBusinessControlAmount='" + itemBusinessControlAmount + '\'' +
                    ", projectPrice='" + projectPrice + '\'' +
                    ", name='" + name + '\'' +
                    ", state=" + state +
                    ", num=" + num +
                    ", value=" + value +
                    ", Invitedtitle='" + Invitedtitle + '\'' +
                    ", Invitedtime='" + Invitedtime + '\'' +
                    ", focusFlag=" + focusFlag +
                    ", telephone='" + telephone + '\'' +
                    ", orderNo='" + orderNo + '\'' +
                    ", lat='" + lat + '\'' +
                    ", lng='" + lng + '\'' +
                    ", bidtype='" + bidtype + '\'' +
                    '}';
        }
    }

    public class TelEntity {
        String tel;
        boolean isUpdate;

        public boolean isUpdate() {
            return isUpdate;
        }

        public void setUpdate(boolean update) {
            isUpdate = update;
        }

        public String getTel() {
            return tel;
        }

        public void setTel(String tel) {
            this.tel = tel;
        }
    }

    public class CompanyEntity {
        String id;
        @SerializedName(value = "companyId", alternate = {"theID"})
        String companyId;
        String typeVc;
        String companyNo;//公司/团队no
        String userNo;//个人no
        String companyName;
        int childPosition = 1;//0 机械,1,设备,2车辆,3,房产,4土地,5工厂 二级
        int position = 0; // type = member ("0商品", "1租赁经营", "2招采经营","3集采管理", "4工程工队","5企业经营") 一级
        String type; // 区分跳转模块

        public int getPosition() {
            return position;
        }

        public void setPosition(int position) {
            this.position = position;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public void setTypeVc(String typeVc) {
            this.typeVc = typeVc;
        }

        public String getTypeVc() {
            return typeVc;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getCompanyId() {
            return companyId;
        }

        public void setCompanyId(String companyId) {
            this.companyId = companyId;
        }

        public String getCompanyNo() {
            return companyNo;
        }

        public void setCompanyNo(String companyNo) {
            this.companyNo = companyNo;
        }

        public String getUserNo() {
            return userNo;
        }

        public void setUserNo(String userNo) {
            this.userNo = userNo;
        }

        public String getCompanyName() {
            return companyName;
        }

        public void setCompanyName(String companyName) {
            this.companyName = companyName;
        }

        public int getChildPosition() {
            return childPosition;
        }

        public void setChildPosition(int childPosition) {
            this.childPosition = childPosition;
        }

    }

    /**
     * 跳转企业、个人、团队、组织网站
     * siteNo 网站ID（虚拟概念），必填字段
     * 1、当siteType类型为企业时，siteNo等于公司no   1
     * 2、当siteType类型为个人时，siteNo等于用户no   0
     * 3、当siteType类型为团队时，siteNo等于团队no   2
     * 4、当siteType类型为组织时，siteNo等于组织no   3
     */
    public class WebsiteEntity {
        public String siteNo;//网站no
        public int siteType = 1;//身份
    }

    public void jumpLogin() {
        VerificationCodeLoginActivity.start(getActivity(), EventConstant.EVENT_WEB_VIEW_JUMP);
    }

    public void checkTokenView() {
        Intent intent = new Intent();
        intent.putExtra("showPage", "FRAGMENT_SHOPPING");
        MainActivity.start(getActivity(), intent);
    }

    public void toLogin() {
        SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.resourceAPPToken, "");
        SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.resourcePCToken, "");
        SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.LOGIN_TOKEN, "");
        SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.LOGIN_PHONE, "");
        getActivity().runOnUiThread(() -> MToast.showToast(getActivity(), "登录失效，请重新登录"));
        jumpLogin();
    }

    public void checkAllowBid(String type, int value, int state) {
        EnterpriseBiddingActivity5.start(
                getActivity(),
                type,
                id,
                value,
                state, lat, lng, historyUrl);
        getActivity().finish();
    }

    public void getUserMsgSucceed(UserMsgEntity userMsgEntity) {
        LoginEvent loginEvent = new LoginEvent();
        loginEvent.setMessageTag(EventConstant.EVENT_USER_MSG);
        loginEvent.setMessageData(userMsgEntity);
        EventBus.getDefault().postSticky(loginEvent);
    }

    /**
     * 一键登录成功
     *
     * @param loginEntity
     * @param phoneNumber
     */
    public void loginSucceed(LoginEntity loginEntity, String phoneNumber) {
        LoginEvent loginEvent = new LoginEvent();
        loginEvent.setMessageData(phoneNumber);
        loginEvent.setMessageTag(EventConstant.EVENT_WEB_VIEW_JUMP);
        loginEvent.setObject(loginEntity);
        EventBus.getDefault().postSticky(loginEvent);
    }

    //打电话
    public void showDialog(String phone) {
        View view = View.inflate(getActivity(), R.layout.dialog_two_btn, null);
        final RoundCornerDialog roundCornerDialog = new RoundCornerDialog(getActivity(), 0, 0, view, R.style.RoundCornerDialog);
        roundCornerDialog.show();
        roundCornerDialog.setCanceledOnTouchOutside(false);// 设置点击屏幕Dialog不消失

        TextView tv_message = (TextView) view.findViewById(R.id.tv_message);
        TextView tv_title = view.findViewById(R.id.tv_title);
        TextView tv_logout_confirm = (TextView) view.findViewById(R.id.tv_logout_confirm);
        tv_title.setVisibility(View.VISIBLE);
        TextView tv_logout_cancel = (TextView) view.findViewById(R.id.tv_logout_cancel);
        tv_title.setText("确认呼叫");
        tv_message.setText(phone);

        //确定
        tv_logout_confirm.setOnClickListener(v -> {

            Intent intent = new Intent(Intent.ACTION_DIAL);
            Uri data = Uri.parse("tel:" + phone);
            intent.setData(data);
            getActivity().startActivity(intent);

            roundCornerDialog.dismiss();
        });

        //取消
        tv_logout_cancel.setOnClickListener(v -> roundCornerDialog.dismiss());
    }


    public void showDialog() {
        View view = View.inflate(getActivity(), R.layout.dialog_two_btn, null);
        final RoundCornerDialog roundCornerDialog = new RoundCornerDialog(getActivity(), 0, 0, view, R.style.RoundCornerDialog);
        roundCornerDialog.show();
        roundCornerDialog.setCanceledOnTouchOutside(false);// 设置点击屏幕Dialog不消失

        TextView tv_message = (TextView) view.findViewById(R.id.tv_message);
        TextView tv_title = view.findViewById(R.id.tv_title);
        TextView tv_logout_confirm = (TextView) view.findViewById(R.id.tv_logout_confirm);
        tv_title.setVisibility(View.VISIBLE);
        TextView tv_logout_cancel = (TextView) view.findViewById(R.id.tv_logout_cancel);
        tv_title.setText("提示");
        tv_message.setText("你需要进行认证后才能操作，去认证");

        //确定
        tv_logout_confirm.setOnClickListener(v -> {
            CertificationActivity.start(getActivity());
            roundCornerDialog.dismiss();
        });

        //取消
        tv_logout_cancel.setOnClickListener(v -> roundCornerDialog.dismiss());
    }

    public void checkAllowDialog(String msg) {
        View view = View.inflate(getActivity(), R.layout.dialog_two_btn, null);
        final RoundCornerDialog roundCornerDialog = new RoundCornerDialog(getActivity(), 0, 0, view, R.style.RoundCornerDialog);
        roundCornerDialog.show();
        roundCornerDialog.setCanceledOnTouchOutside(false);// 设置点击屏幕Dialog不消失
        TextView tv_message = view.findViewById(R.id.tv_message);
        TextView tv_title = view.findViewById(R.id.tv_title);
        TextView tv_logout_confirm = view.findViewById(R.id.tv_logout_confirm);
        TextView tv_logout_cancel = view.findViewById(R.id.tv_logout_cancel);

        tv_logout_cancel.setVisibility(View.GONE);
        tv_title.setVisibility(View.VISIBLE);
        tv_title.setText("提示");

        tv_message.setText(msg);

        //确定
        tv_logout_confirm.setOnClickListener(v -> roundCornerDialog.dismiss());
    }


    @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
    public void onEvent(LoginEvent event) {
        if (event.getMessageTag() == EventConstant.EVENT_WEB_VIEW_JUMP || event.getMessageTag() == EventConstant.EVENT_LOGIN_OUT) {
            Log.v("tokkk", "event");
            binding.webViewX5.callHandler(WebJsConstants.RECV_TOKEN, new Gson().toJson(getMapToken()), data -> {
            });
            binding.webViewX5.loadUrl(url);
            binding.webViewX5.reLoadView();
        } else if (event.getMessageTag() == EventConstant.EVENT_FINISH_H5) {
            if (getActivity() != null) {
                getActivity().finish();
            }
        }
    }
    //原原生开发的报价列表改为 由 H5 开发，避免原生和h5之间重复循环跳转
//    @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
//    public void onEvent(AskLeaseLookEvent event) {
//        if (null != event) {
//            binding.include.rightView.setText("查看报价");
//            binding.include.rightView.setVisibility(View.VISIBLE);
//            binding.include.rightView.setOnClickListener(v -> {
//                MyAskLeaseQutedListActivity.start(getActivity(), event.getId(), event.getType());
//            });
//        }
//    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    //认证dialog
    private void showDialogAuth(String type) {
        View view = View.inflate(getActivity(), R.layout.dialog_two_btn, null);
        final RoundCornerDialog roundCornerDialog = new RoundCornerDialog(getActivity(), 0, 0, view, R.style.RoundCornerDialog);
        roundCornerDialog.show();
        roundCornerDialog.setCanceledOnTouchOutside(false);// 设置点击屏幕Dialog不消失

        TextView tv_message = (TextView) view.findViewById(R.id.tv_message);
        TextView tv_title = view.findViewById(R.id.tv_title);
        TextView tv_logout_confirm = (TextView) view.findViewById(R.id.tv_logout_confirm);
        tv_title.setVisibility(View.VISIBLE);
        TextView tv_logout_cancel = (TextView) view.findViewById(R.id.tv_logout_cancel);

        if (type.equals("manager")) {
            tv_title.setText("认证");
            tv_message.setText("请先进行企业认证再操作");
        } else if (type.equals("driver")) {
            tv_title.setText("认证");
            tv_message.setText("请先进行司机认证再操作");

        } else if (type.equals("nocar")) {
            tv_title.setText("无可用车辆");
            tv_message.setText("请先添加车辆");
            tv_logout_confirm.setText("去添加");

        } else if (type.equals("driverFail")) {
            tv_title.setText("司机认证不通过");
            tv_message.setText("请重新提交认证信息");

        } else if (type.equals("managerFail")) {
            tv_title.setText("企业认证审核不通过");
            tv_message.setText("请重新提交认证信息");

        } else if (type.equals("driverStandby")) {
            tv_title.setText("司机认证审核中");
            tv_message.setText("认证审核中，不能进行操作");

        } else if (type.equals("managerStandby")) {
            tv_title.setText("企业认证审核中");
            tv_message.setText("认证审核中，不能进行操作");
        }

        //确定
        tv_logout_confirm.setOnClickListener(v -> {
            if (type.equals("manager") || type.equals("managerFail")) {
                AuthActivity3.start(getActivity());

            } else if (type.equals("driver") || type.equals("driverFail")) {
                Intent intent = new Intent(getActivity(), AddDriverInfoActivity.class);
                startActivity(intent);
            } else if (type.equals("nocar")) {
                AddCarActivity.start(getActivity());
            }
            roundCornerDialog.dismiss();
        });

        //取消
        tv_logout_cancel.setOnClickListener(v -> roundCornerDialog.dismiss());
    }

    public void showCarInfo(List<CarInfo> carInfo) {
        this.carInfo = carInfo;
    }

    private void showDialog(String title, String content, int type, String orderNo) {
        View view = View.inflate(getActivity(), R.layout.dialog_two_btn, null);
        final RoundCornerDialog roundCornerDialog = new RoundCornerDialog(getActivity(), 0, 0, view, R.style.RoundCornerDialog);
        roundCornerDialog.show();
        roundCornerDialog.setCanceledOnTouchOutside(false);// 设置点击屏幕Dialog不消失
        TextView tv_title = view.findViewById(R.id.tv_title);
        TextView tv_message = view.findViewById(R.id.tv_message);
        TextView tv_logout_confirm = view.findViewById(R.id.tv_logout_confirm);
        TextView tv_logout_cancel = view.findViewById(R.id.tv_logout_cancel);
        tv_title.setVisibility(View.VISIBLE);
        tv_title.setText(title);
        tv_message.setText(content);

        //确定
        tv_logout_confirm.setOnClickListener(v -> {
            //请求接口
            switch (type) {
                case 0:
                    viewModel.confirm(orderNo);
                    break;
                case 1:
                    viewModel.cancel(orderNo);
                    break;
                case 2:
                    viewModel.delOrder(orderNo);
                    break;
                case 3:
                    viewModel.startCar(orderNo);
                    break;
                case 4:
                    viewModel.endCar(orderNo);
                    break;
            }
            roundCornerDialog.dismiss();
        });
        //取消
        tv_logout_cancel.setOnClickListener(v -> roundCornerDialog.dismiss());
    }

    //非登录引起的h5刷新且不需要传值可用次方法刷新h5详情页
    @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
    public void onEvent(WebEvent event) {
        if (event.getMessageTag() == EventConstant.EVENT_WEBVIEW_RELOAD) {
            initView();
            binding.webViewX5.reLoadView();
        } else if (event.getMessageTag() == EventConstant.EVENT_WEBVIEW_GOBACK) {
            if (binding.webViewX5.canGoBack()) {
                binding.webViewX5.goBack();
            } else {
                getActivity().onBackPressed();
            }
        }
    }

    //在H5调用app原生支付成功后，返回刷新H5
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void refreshH5ByPay(ZMessageEvent event) {
        if (event.code == Constants.EVENT_PAY_SUCCESS) {
            binding.webViewX5.reLoadView();
        }
    }

    public void setTvIsGz(int isGz) {
        //标是否关注
        int focusFlag;
        if (isGz == 1) {
            focusFlag = 0;
            MToast.showToast(getActivity(), "取消关注");
        } else {
            focusFlag = 1;
            MToast.showToast(getActivity(), "关注成功");
        }
        showTvIsGz(focusFlag);
    }

    public void showTvIsGz(int isGz) {
        //标是否关注
        if (isGz == 1) {
            binding.include.rightImageView.setBackgroundResource(R.drawable.ic_heart_gray);
        } else {
            binding.include.rightImageView.setBackgroundResource(R.drawable.ic_heart_blue);
        }
    }

    public void showImWindow(List<EnquiryImAlternateEntity.CompanyCustomersDTO> companyCustomers) {
        if (companyCustomers.size() == 1) {
            if (companyCustomers.get(0) != null && !TextUtils.isEmpty(String.valueOf(companyCustomers.get(0).getImAccount()))) {
                IMUtils.getInstance().buildSingleTalking(String.valueOf(companyCustomers.get(0).getImAccount()));
            }
        } else {
            List<CallPhoneEntity> datas = new ArrayList<>();
            for (int i = 0; i < companyCustomers.size(); i++) {
                CallPhoneEntity entity = new CallPhoneEntity();
                entity.setType("1");
                entity.setPrincipalName(companyCustomers.get(i).getPrincipalName());
                entity.setImAccount(companyCustomers.get(i).getImAccount());
                entity.setImToken(companyCustomers.get(i).getImToken());
                datas.add(entity);
            }
            CallPhonePopWindow window = new CallPhonePopWindow(getActivity());
            window.setBgView(binding.grayLayout);
            window.setData(datas);
            if (!window.isShowing()) {
                window.showDownPopwindow(binding.grayLayout, true);
            }
        }
    }

    public void updateProcessStatus(String status, QualityMemberBean memberBean) {
        // 有审批时：弹出审批确认弹窗，具体如原型所示，点击去填写跳转到邀请审批信息填写页
        // 无审批时：点击去填写跳转到邀请信息填写页
        if (status.equals("1")) {
            MemberCommonDialog dialog = new MemberCommonDialog(new MemberCommonDialog.SimpleListener() {
                @Override
                public void onPositive(Object... objects) {
                    // 跳转填写审批信息// 审批类型 1 申请加盟(固定传1就行) 2邀请加盟
                    jumpJoinPage(status, memberBean);
                }
            }, MemberCommonDialog.STYLE_INVITE_JOIN);
            dialog.show(getActivity(), "MemberCommonDialog");
        } else {
            jumpJoinPage(status, memberBean);
        }
    }

    private void jumpJoinPage(String status, QualityMemberBean bean) {
        // 跳转邀请加盟申请页
        switch (bean.getApproveType()) {
            case "2": // 邀请加盟
                if (MemberConfig.getInstance().getComType() == MemberConfig.WEBSITE_FOR_PERSONAL) {
                    PersonInviteJoinActivity.start(getActivity(), bean, false);//个人 邀请 企业
                } else {
                    if (bean.getUserType().equals("1")) {
                        MemberInviteJoinActivity.start(getActivity(), bean);//企业 邀请 企业
                    } else {
                        if (status.equals("1")) {//有审批
                            ComApplyOrInvitePersonShenPiActivity.start(requireActivity(), bean, false, 0);
                        } else {
                            ComApplyOrInvitePersonActivity.start(requireActivity(), bean, false, 0); //    企业  邀请  个人
                        }
                    }
                }
                break;
            case "1": // 申请加盟
                if (MemberConfig.getInstance().getComType() == MemberConfig.WEBSITE_FOR_PERSONAL) {
                    PersonApplyJoinActivity.start(getActivity(), bean, false);//个人 申请 企业
                } else {
                    if (bean.getUserType().equals("1")) {
                        MemberApplyJoinActivity.start(getActivity(), bean);//企业 申请 企业
                    } else {
                        if (status.equals("1")) {//有审批
                            ComApplyOrInvitePersonShenPiActivity.start(requireActivity(), bean, false, 1);
                        } else {
                            ComApplyOrInvitePersonActivity.start(requireActivity(), bean, false, 1);  //    企业  申请  个人
                        }
                    }
                }
                break;
        }
    }
}
